vite-plugin-comlink icon indicating copy to clipboard operation
vite-plugin-comlink copied to clipboard

Cannot make it to work with SharedWorker

Open pvcnt opened this issue 1 year ago • 1 comments

Describe the bug I am trying to use this plugin with a SharedWorker, and hit the following error:

TypeError: ep.postMessage is not a function
    requestResponseMessage comlink.ts:613
    requestResponseMessage comlink.ts:601
    apply comlink.ts:504

I did some debugging and ep is an instance of SharedWorker, which indeed does not have a postMessage method (ep.port has though).

To Reproduce I am using the following snippet:

const worker = new ComlinkSharedWorker<typeof import("./worker")>(
    new URL("./worker", import.meta.url), {type: "module"}
);
await worker.refresh();

Expected behavior It should work.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Firefox
  • Version [e.g. 22]: 127.0.2

pvcnt avatar Jul 08 '24 15:07 pvcnt

This is a bug created with my 5.0 refactoring.

mathe42 avatar Jul 08 '24 21:07 mathe42