Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js 11.7+ supports Worker + related updates #25012

Merged
merged 10 commits into from
Jan 28, 2025

Conversation

skyclouds2001
Copy link
Contributor

@skyclouds2001 skyclouds2001 commented Nov 9, 2024

Summary

initially added via nodejs/node#20876, in https://nodejs.org/zh-cn/blog/release/v10.5.0, need to be enabled by --experimental-worker runtime CLI flag

exposed via module and remove the runtime CLI flag via nodejs/node#25361, in https://nodejs.org/zh-cn/blog/release/v11.7.0

see https://nodejs.org/docs/latest/api/worker_threads.html#class-worker, note that the doc has no info about the experimental status between v10.5.0 and v11.7.0, the issue fired at nodejs/node#55794

update the data for Worker, as there is already a ecmascript_modules field shows the ESM support

the data for error event is confirmed with the intial pr nodejs/node#20876

the data for messageerror event and terminate() method come from the documentation, also confirmed by release and impl pr

https://nodejs.org/zh-cn/blog/release/v12.19.0
https://nodejs.org/zh-cn/blog/release/v14.5.0
nodejs/node#33772

https://nodejs.org/zh-cn/blog/release/v12.5.0
nodejs/node#28021

Test results and supporting details

confirmed by landing PRs and release notes

also test in local node runtime:

image

image

Related issues

@github-actions github-actions bot added the data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Nov 9, 2024
@skyclouds2001 skyclouds2001 marked this pull request as ready for review November 9, 2024 00:30
api/Worker.json Outdated Show resolved Hide resolved
@caugner caugner added the nodejs Data about Node.js label Nov 12, 2024
@github-actions github-actions bot added the merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. label Nov 18, 2024
Copy link

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. label Nov 18, 2024
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
@github-actions github-actions bot added the size:l [PR only] 101-1000 LoC changed label Nov 23, 2024
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <[email protected]>
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
api/Worker.json Outdated Show resolved Hide resolved
Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <[email protected]>
@caugner
Copy link
Contributor

caugner commented Jan 13, 2025

@queengooborg Can you PTAL at this PR when you have a moment?

Comment on lines +25 to +33
"nodejs": {
"version_added": "11.7.0",
"partial_implementation": true,
"notes": [
"Inherits from a Node `EventEmitter` instead of DOM `EventTarget`.",
"Also supports CommonJS modules, enabled for files ending with `.cjs` and for files ending with `.js` when the nearest parent `package.json` file contains a top-level field `\"type\"` with a value not of `\"commonjs\"`.",
"Available as a part of the `worker_threads` module."
]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Verified that worker_threads.Worker exists in v12.0.0, which seems to be the gist of this change.

Comment on lines +80 to +84
"nodejs": {
"version_added": "11.7.0",
"partial_implementation": true,
"notes": "Takes entirely different options parameters."
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Makes sense based on parent change.

Comment on lines +303 to +305
"nodejs": {
"version_added": "11.7.0"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Verified locally with this worker.js, created via new worker_threads.Worker('./worker.js'):

const { Worker } = require('worker_threads');
const { writeFileSync } = require('fs');

writeFileSync('./worker.log', Worker, 'utf-8');

Comment on lines +347 to +349
"version_added": "11.7.0",
"partial_implementation": true,
"notes": "Supports the event, but only via Node `EventEmitter`."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Verified locally.

Comment on lines +401 to +405
"nodejs": {
"version_added": "11.7.0",
"partial_implementation": true,
"notes": "Supports the event, but only via Node `EventEmitter`."
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Makes sense based on parent change.

Comment on lines +454 to +466
"nodejs": [
{
"version_added": "14.5.0",
"partial_implementation": true,
"notes": "Supports the event, but only via Node `EventEmitter`."
},
{
"version_added": "12.19.0",
"version_removed": "13.0.0",
"partial_implementation": true,
"notes": "Supports the event, but only via Node `EventEmitter`."
}
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Verified via the referenced PR.

api/Worker.json Outdated
Comment on lines 541 to 548
"nodejs": {
"version_added": "11.7.0",
"partial_implementation": true,
"notes": [
"The options parameter is not supported; the second parameter may only be an array of objects to transfer.",
"Only supports transferring `ArrayBuffer` and `MessagePort` objects."
]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Makes sense based on parent change.

New note:

The options parameter is not supported; the second parameter may only be an array of objects to transfer.

},
{
"version_added": "11.7.0",
"partial_implementation": true,
"notes": "Also takes an optional callback to be executed when the worker has terminated."
"notes": "Takes an optional callback parameter to be executed when the worker has terminated."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Both verified locally.

api/Worker.json Outdated Show resolved Hide resolved
Co-authored-by: Claas Augner <[email protected]>
@caugner caugner changed the title Update nodejs data for Worker Node.js 11.7+ supports Worker + related updates Jan 28, 2025
@caugner caugner dismissed queengooborg’s stale review January 28, 2025 13:48

Requested changes were applied.

@caugner caugner merged commit 531c731 into mdn:main Jan 28, 2025
7 checks passed
@skyclouds2001 skyclouds2001 deleted the node-worker branch January 28, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API nodejs Data about Node.js size:l [PR only] 101-1000 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants