From 1b87859cb777f918fec532117d70ec742a78d538 Mon Sep 17 00:00:00 2001 From: RomanYar Date: Tue, 10 Nov 2020 14:58:10 +0200 Subject: [PATCH] com: avoid redundent forwarding of messages --- packages/core/src/com/communication.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/core/src/com/communication.ts b/packages/core/src/com/communication.ts index 85e53f007..ca6116567 100644 --- a/packages/core/src/com/communication.ts +++ b/packages/core/src/com/communication.ts @@ -1,11 +1,4 @@ -import { - CALLBACK_TIMEOUT, - DUPLICATE_REGISTER, - MISSING_ENV, - REMOTE_CALL_FAILED, - reportError, - UNKNOWN_CALLBACK_ID, -} from './errors'; +import { CALLBACK_TIMEOUT, DUPLICATE_REGISTER, REMOTE_CALL_FAILED, reportError, UNKNOWN_CALLBACK_ID } from './errors'; import { isWindow, isWorkerContext, MultiCounter } from './helpers'; import type { CallbackMessage, @@ -520,14 +513,10 @@ export class Communication { } } private sendTo(envId: string, message: Message): void { - const start = this.resolveMessageTarget(envId); - if (!start) { - throw new Error(MISSING_ENV(envId, Object.keys(this.environments))); - } if (this.pendingEnvs.get(envId)) { - this.pendingMessages.add(envId, () => this.post(start, message)); + this.pendingMessages.add(envId, () => this.post(this.resolveMessageTarget(envId), message)); } else { - this.post(start, message); + this.post(this.resolveMessageTarget(envId), message); } }