microsoft / microsoft/vscode-wasm

Sync-Api doesn't work with multiple workers

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
TypeScript
Stars
456
Forks
40
Avg merge
3d 2h
Merged PRs (30d)
4

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the sync-api MessageChannel setup across the worker hierarchy described in the issue, then reproduce the CPython debugger scenario with Emscripten's filesystem proxying. Done means nested workers can communicate with the Main Thread without the Atomics.wait deadlock.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, wasm
Domain
distributed-systems, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.