GoogleChromeLabs / GoogleChromeLabs/comlink
Web Worker Hangs if Imported File Contains Top-Level `Await`
- Dominant language
- TypeScript
- Stars
- 12.8k
- Forks
- 435
- PR merge metrics
- No merged PRs in 30d
Description
Whatever your thoughts are on top-level await, I'm initializing a library using `await`. However, the web worker seems to hang once it encounters the `await`, preventing the rest of the web worker from executing. Any imported file with a top-level await causes this.
I've made a [reproducible example](https://codesandbox.io/p/sandbox/silly-sun-hz4zsj) (make sure to use a Chromium browser). If the `count is {count}` button is clicked, the `getNumberPlusOne` function in `fakeTopLevelAwait` won't work. If the await is commented out, `getNumberPlusOne` executes successfully.
I'd like to know if this a limitation in Web Workers or comlink. I'd really like to get this working. And kudos on such a fantastic lib!
Contributor guide
Assessment
This issue has not been assessed yet.