Skip to content

http,https,http2: make async disposers idempotent #58832

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LiviaMedeiros
Copy link
Member

This PR makes server[Symbol.asyncDispose] calls not throw after the server is already closed.

{
  await using server = {http,https,http2}.createServer();
  server.listen();
  await server.close(); // close explicitly, throws if server is not running
} // close implicitly, does nothing if server is not running

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. http2 Issues or PRs related to the http2 subsystem. https Issues or PRs related to the https subsystem. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Jun 25, 2025
@@ -580,10 +578,6 @@ Server.prototype.close = function close() {
return this;
};

Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm does this make this a semver-major? This becomes a user observable change and if someone happens to be using an ERM polyfill I can imagine removing this breaking things.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I forgot that disposers graduated from experimental state since v24.2.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to split this into two patches, one to make the existing http* overrides idempotent, and another semver-major one to remove them?

@LiviaMedeiros LiviaMedeiros added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 25, 2025
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.08%. Comparing base (faada65) to head (8136261).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58832      +/-   ##
==========================================
- Coverage   90.09%   90.08%   -0.02%     
==========================================
  Files         640      640              
  Lines      188271   188356      +85     
  Branches    36923    36940      +17     
==========================================
+ Hits       169625   169675      +50     
- Misses      11386    11402      +16     
- Partials     7260     7279      +19     
Files with missing lines Coverage Δ
lib/_http_server.js 97.05% <ø> (-0.02%) ⬇️
lib/https.js 99.29% <ø> (-0.01%) ⬇️
lib/internal/http2/core.js 95.15% <ø> (-0.01%) ⬇️
lib/net.js 95.28% <100.00%> (+<0.01%) ⬆️

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

@LiviaMedeiros LiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 25, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 25, 2025
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. http2 Issues or PRs related to the http2 subsystem. https Issues or PRs related to the https subsystem. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants