From 2884b17503ce9516a701302820e04939d389bd3e Mon Sep 17 00:00:00 2001 From: Adam Zielinski Date: Wed, 6 Mar 2024 10:36:15 +0100 Subject: [PATCH] Comlink API: Pass the context argument to windowEndpoint, not wrap (#1087) Follows up on #1085 that correctly identified the issue with `postMessage` event handlers, but passed the context argument to the wrong function call. `wrap()` uesd in that PR is not responsible for binding the message event handler. `windowEndpoint()` is. This PR fixes the mistake. --- packages/php-wasm/web/src/lib/api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/php-wasm/web/src/lib/api.ts b/packages/php-wasm/web/src/lib/api.ts index ce1632106e..ea92562533 100644 --- a/packages/php-wasm/web/src/lib/api.ts +++ b/packages/php-wasm/web/src/lib/api.ts @@ -22,7 +22,9 @@ export function consumeAPI( setupTransferHandlers(); const endpoint = - remote instanceof Worker ? remote : Comlink.windowEndpoint(remote); + remote instanceof Worker + ? remote + : Comlink.windowEndpoint(remote, context); /** * This shouldn't be necessary, but Comlink doesn't seem to @@ -33,7 +35,7 @@ export function consumeAPI( * * @TODO: Remove this workaround. */ - const api = Comlink.wrap(endpoint, context); + const api = Comlink.wrap(endpoint); const methods = proxyClone(api); return new Proxy(methods, { get: (target, prop) => {