fix: properly close idle connections in test server cleanup#4764
Merged
fix: properly close idle connections in test server cleanup#4764
Conversation
a1571a7 to
e037410
Compare
Updated 13 test files to call server.closeAllConnections?.() before closing servers in after() hooks. This ensures all connections (both idle and active) are forcefully closed when the method is available (http.Server), preventing test timeouts. Uses optional chaining to safely handle net.Server which lacks this method. Files updated: - test/fetch/encoding.js - test/fetch/client-node-max-header-size.js - test/client-node-max-header-size.js - test/client-request.js - test/env-http-proxy-agent-nodejs-bundle.js - test/issue-4244.js - test/max-response-size.js - test/mock-agent.js - test/mock-client.js - test/mock-pool.js - test/no-strict-content-length.js - test/request.js - test/snapshot-testing.js Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
e037410 to
d4a9277
Compare
Replace async after() hooks with synchronous ones to avoid "Promise resolution is still pending but the event loop has already resolved" errors. The pattern `server.closeAllConnections?.()` followed by `server.close()` properly handles connection cleanup without needing to await. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4764 +/- ##
=======================================
Coverage 93.26% 93.26%
=======================================
Files 109 109
Lines 34029 34029
=======================================
Hits 31738 31738
Misses 2291 2291 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merged
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server.closeIdleConnections()before closing servers inafter()hooksECONNRESETerrors on macOSFiles updated
Test plan
🤖 Generated with Claude Code