Skip to content

Commit a8533a9

Browse files
committed
Specify method when proxy doesn't exist
1 parent 95ef2ee commit a8533a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/protocol/src/node/server.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class Server {
138138

139139
let response: any;
140140
try {
141-
const proxy = this.getProxy(proxyId);
141+
const proxy = this.getProxy(proxyId, method);
142142
if (typeof proxy.instance[method] !== "function") {
143143
throw new Error(`"${method}" is not a function`);
144144
}
@@ -231,7 +231,7 @@ export class Server {
231231
// It might have finished because we disposed it due to a disconnect.
232232
if (!this.disconnected) {
233233
this.sendEvent(proxyId, "done");
234-
this.getProxy(proxyId).disposeTimeout = setTimeout(() => {
234+
this.getProxy(proxyId, "disposeTimeout").disposeTimeout = setTimeout(() => {
235235
instance.dispose();
236236
this.removeProxy(proxyId);
237237
}, this.responseTimeout);
@@ -317,7 +317,7 @@ export class Server {
317317
* Call after disposing a proxy.
318318
*/
319319
private removeProxy(proxyId: number | Module): void {
320-
clearTimeout(this.getProxy(proxyId).disposeTimeout as any);
320+
clearTimeout(this.getProxy(proxyId, "disposeTimeout").disposeTimeout as any);
321321
this.proxies.delete(proxyId);
322322

323323
logger.trace(() => [
@@ -331,9 +331,9 @@ export class Server {
331331
return stringify(value, undefined, (p) => this.storeProxy(p));
332332
}
333333

334-
private getProxy(proxyId: number | Module): ProxyData {
334+
private getProxy(proxyId: number | Module, method: string): ProxyData {
335335
if (!this.proxies.has(proxyId)) {
336-
throw new Error(`proxy ${proxyId} disposed too early`);
336+
throw new Error(`Cannot run "${method}" on proxy ${proxyId}: proxy does not exist`);
337337
}
338338

339339
return this.proxies.get(proxyId)!;

0 commit comments

Comments
 (0)