Skip to content

workers: make Worker async disposable #58385

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

Closed
wants to merge 2 commits into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented May 19, 2025

await using worker = new Worker(...);

@jasnell jasnell added semver-minor PRs that contain new features and should be released in the next minor version. worker Issues and PRs related to Worker support. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. labels May 19, 2025
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label May 19, 2025
@jasnell jasnell requested review from mcollina, addaleax and anonrig May 19, 2025 02:37
@nodejs-github-bot

This comment was marked as outdated.

Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.19%. Comparing base (cf5cbff) to head (102558e).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58385      +/-   ##
==========================================
- Coverage   90.20%   90.19%   -0.02%     
==========================================
  Files         635      635              
  Lines      187224   187229       +5     
  Branches    36770    36774       +4     
==========================================
- Hits       168889   168862      -27     
- Misses      11088    11124      +36     
+ Partials     7247     7243       -4     
Files with missing lines Coverage Δ
lib/internal/worker.js 99.82% <100.00%> (+<0.01%) ⬆️

... and 30 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.

Copy link
Member

@LiviaMedeiros LiviaMedeiros left a comment

Choose a reason for hiding this comment

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

LGTM with or without the nit; and s/^workers/worker/ in the commit message.

Noting that the code change can be safely backported to release lines that have Symbol.asyncDispose but not the ERM itself; and splitting this into two commits (one that adds [SymbolAsyncDispose](), tests it by calling explicitly, and documents without code example; and another for v24+ adding using in tests in docs) might make it more straightforward for releasers.

@aduh95
Copy link
Contributor

aduh95 commented May 19, 2025

Why dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. ? That feels like something we'd want to backport. Could you follow the same approach of #58206, i.e. avoid using the new syntax so this can be backported, and add a TODO to have a follow-up to test with the await using syntax?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@jasnell jasnell force-pushed the jasnell/worker-thread-disposable branch from 658a86f to 9e53faf Compare May 24, 2025 21:04
@jasnell jasnell force-pushed the jasnell/worker-thread-disposable branch from 9e53faf to 102558e Compare May 24, 2025 21:08
@jasnell jasnell removed the dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. label May 24, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@LiviaMedeiros LiviaMedeiros added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label May 25, 2025
@nodejs-github-bot
Copy link
Collaborator

jasnell added a commit that referenced this pull request May 26, 2025
PR-URL: #58385
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
jasnell added a commit that referenced this pull request May 26, 2025
PR-URL: #58385
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@jasnell
Copy link
Member Author

jasnell commented May 26, 2025

Landed in 62855f3...d968227

@jasnell jasnell closed this May 26, 2025
jasnell added a commit to jasnell/node that referenced this pull request May 26, 2025
Manual Backport of nodejs#58385

Original metadata:
    PR-URL: nodejs#58385
    Reviewed-By: LiviaMedeiros <livia@cirno.name>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
    Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@aduh95 aduh95 added the backport-open-v22.x Indicate that the PR has an open backport label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-open-v22.x Indicate that the PR has an open backport commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants