Skip to content

worker: fix Web Worker spec deviations - #66354

Open
panva wants to merge 6 commits into
nodejs:mainfrom
panva:webworker-spec
Open

panva wants to merge 6 commits into
nodejs:mainfrom
panva:webworker-spec

Conversation

@panva

@panva panva commented Sep 27, 2026

Copy link
Copy Markdown
Member

Fix five Web Worker deviations from HTML and Web IDL:

  • Correct postMessage() overload resolution for callable iterables and null iterators, and retrieve Symbol.iterator only once.
  • Convert all importScripts() arguments before rejecting module workers or parsing URLs.
  • Preserve the original blob module URL in import.meta.url.
  • Preserve serialization errors and transfer side effects after worker exit or script fetch failure.
  • Discard queued messages on terminate(), including when called from a message handler, while allowing the current event to finish.

Web IDL overload resolution treats functions as objects, accepts a null
iterator as missing, and retrieves the iterator method only once. Reuse
that method during sequence conversion in both postMessage entry points.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Web IDL converts every argument before entering the method algorithm.
Perform all USVString conversions before rejecting module workers or
parsing URLs, so later conversions can throw or revoke blob URLs first.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Evaluate blob module sources under their original URL instead of
rewrapping them in a data URL. This preserves import.meta.url and module
identity while retaining the captured source after URL revocation.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
The outside port must serialize and transfer messages even when it has
no peer. Retain that port after the backing thread exits and create a
closed port when the entry script fetch fails. This preserves clone
errors and transfer side effects in both cases.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Close the outside port and remove its message forwarding listeners
synchronously. Closing the port alone is asynchronous and can leave
queued messages dispatching when terminate() runs inside a listener.

Allow the current event to finish while discarding subsequent messages,
including those drained when the backing thread exits.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
@panva
panva requested review from avivkeller and jasnell September 27, 2026 17:05
@panva panva added the commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. label Sep 27, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/web-standards

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Sep 27, 2026
@panva panva added the experimental Issues and PRs related to experimental features. label Sep 27, 2026
Comment thread lib/internal/webworker.js
Comment thread lib/internal/webworker.js
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.36%. Comparing base (a2a064c) to head (06ef7b4).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66354   +/-   ##
=======================================
  Coverage   90.36%   90.36%           
=======================================
  Files         792      792           
  Lines      275386   275446   +60     
  Branches    52775    52792   +17     
=======================================
+ Hits       248843   248916   +73     
+ Misses      16979    16949   -30     
- Partials     9564     9581   +17     
Files with missing lines Coverage Δ
lib/internal/webidl.js 100.00% <100.00%> (ø)
lib/internal/webworker.js 95.85% <100.00%> (+2.62%) ⬆️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

This comment has been minimized.

@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 28, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
@nodejs-github-bot

This comment has been minimized.

@panva panva added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Sep 28, 2026
@github-actions github-actions Bot added resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. and removed resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to resume CI

✖  Cannot resume PR CI job 78035: Jenkins does not offer a "Resume build" action. Check the existing CI run in Jenkins and rebase the PR if needed. To start a new CI run manually: ncu-ci run https://github.com/nodejs/node/pull/66354
   ✖  https://ci.nodejs.org/job/node-test-pull-request/78035/
Full Auto Start CI output
�[36m⠋�[39m Validating Jenkins credentials
�[36m⠋�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠙�[39m Looking for CI runs for pull request 66354
�[36m⠙�[39m Looking for CI runs for pull request 66354
�[36m⠙�[39m Getting PR from nodejs/node/pull/66354
�[36m⠙�[39m Getting reviews from nodejs/node/pull/66354
�[36m⠙�[39m Getting comments from nodejs/node/pull/66354
✔  Found PR CI job 78035
�[36m⠹�[39m Querying data for job/node-test-pull-request/78035/
�[36m⠹�[39m Querying data for job/node-test-pull-request/78035/
�[36m⠹�[39m Querying API for job/node-test-pull-request/78035/
✔  Build data downloaded
�[36m⠹�[39m Checking whether PR CI job 78035 can be resumed
�[36m⠹�[39m Checking whether PR CI job 78035 can be resumed
✖  Cannot resume PR CI job 78035: Jenkins does not offer a "Resume build" action. Check the existing CI run in Jenkins and rebase the PR if needed. To start a new CI run manually: ncu-ci run https://github.com/nodejs/node/pull/66354
   ✖  https://ci.nodejs.org/job/node-test-pull-request/78035/

View workflow run

@panva panva removed the resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. label Sep 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. experimental Issues and PRs related to experimental features. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants