Open
Description
Suppose you have something like so:
Main Thread - Extension code
Worker 1 - Extension sub piece, which starts Worker 2
Worker 2 - Needs to use the sync api
Worker 2 cannot communicate with the Main Thread because its MessageChannel is only with Worker 1.
For CPython I have this exact situation when trying to run the debugger:
- Main thread - Extension code
- Worker 1 - Load of python.js
- Worker 2 - Reader thread for debugger
- Worker 3 - Writer thread for debugger
Worker 2 and 3 cannot send messages to the Main Thread.
- Note: Emscripten (by default proxies) all FS (or socket) API calls to its main thread (worker 1 in this case) but that causes deadlock issues because the Atomics.wait in the sync-api block the main worker thread, therefore no other fs API calls can be handled while waiting. Took me a while to figure this out as most of it was working until Worker 3 tried to acquire a lock.