You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// index.tsimport*asComlinkfrom"comlink";import{dummyTask}from"./task.js";consturl=newURL("./worker.js",import.meta.url);constwrapper: Comlink.Remote<{dummy: ()=>number;}>=Comlink.wrap(newWorker(url,{type: "module"}));// Works without problem with this line// await dummyTask(1000);// Never returnsconstx=awaitwrapper.dummy();// Unreachableconsole.log(x);
The text was updated successfully, but these errors were encountered:
Yes I got the same problem. I can think of 2 workarounds:
At the end of the file (or the last expose instruction) the worker could postMessage that he is done. The caller could then wait for this signal.
Be sure that you workers first define/declare and expose before any code is actually run.
The first idea could be built into comlink with some function like initialized or finalExportwhich the worker/exposer would call after everything has been exposed.
Problem description
Wrapped function does not return when called before the worker is ready.
Minimum codes to reproduce
Deps.
The text was updated successfully, but these errors were encountered: