From 182ed6ad71c307cedcf8a30dcddf5aa9da558222 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 7 Jan 2022 09:55:29 -0800 Subject: [PATCH] rpc: watch for peer death on apply --- server/src/rpc.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/rpc.ts b/server/src/rpc.ts index a1151b127..1ba2af248 100644 --- a/server/src/rpc.ts +++ b/server/src/rpc.ts @@ -135,6 +135,9 @@ class RpcProxy implements PrimitiveProxyHandler { } apply(target: any, thisArg: any, argArray?: any): any { + if (Object.isFrozen(this.peer.pendingResults)) + return Promise.reject(new RPCResultError(this.peer, 'RpcPeer has been killed')); + // rpc objects can be functions. if the function is a oneway method, // it will have a null in the oneway method list. this is because // undefined is not JSON serializable.