Skip to content

Feature/web worker#5148

Draft
yush-1018 wants to merge 12 commits intoboa-dev:mainfrom
yush-1018:feature/web-worker
Draft

Feature/web worker#5148
yush-1018 wants to merge 12 commits intoboa-dev:mainfrom
yush-1018:feature/web-worker

Conversation

@yush-1018
Copy link
Contributor

This is a Draft PR implementing the foundation for the Web Worker API (Worker class) in boa_runtime.

What this PR does

  1. Adds a new worker module in core/runtime/src/worker/
  2. new Worker("script.js") spawns a fresh OS thread with its own Context and runs the given script file
  3. worker.postMessage(msg) sends a string message to the worker thread using Rust's mpsc channels
  4. worker.terminate() is stubbed out for now
  5. Registered as a WorkerExtension in the runtime, so it's available out of the box
  6. Added a basic smoke test

What's missing (and where I'd love some guidance )
This is intentionally a Draft — I wanted to get the architecture right before going further. A few things I'm unsure about:

  1. Worker → Main thread messaging — How should onmessage work on the main thread side? Should we poll via run_jobs(), or is there a plan for a proper event loop in boa_runtime?
  2. Structured Clone vs simple JSON — Right now I'm only sending strings. Should I go for full Structured Clone, or is a JSON-based approach fine as a starting point?
  3. Worker global scope — The worker's Context is pretty bare right now (no console, setTimeout, etc.). What's the best way to bootstrap a DedicatedWorkerGlobalScope without creating circular deps with boa_runtime?
  4. terminate() — Should I use engine interrupts to actually kill the worker thread?

Happy to iterate on any of this based on your feedback. Thanks for your time! 😊

@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 19, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 19, 2026
@github-actions github-actions bot added C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics C-Runtime Issues and PRs related to Boa's runtime features labels Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant