test: add unexpected disconnect guards to more client test files#4844
test: add unexpected disconnect guards to more client test files#4844metcoder95 merged 12 commits intonodejs:mainfrom
Conversation
5c94a36 to
8e69a9f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4844 +/- ##
==========================================
- Coverage 93.02% 93.01% -0.02%
==========================================
Files 112 112
Lines 35157 35157
==========================================
- Hits 32705 32701 -4
- Misses 2452 2456 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a88b414 to
8e69a9f
Compare
Signed-off-by: Sam Mayer <[email protected]> Signed-off-by: Sam Mayer <[email protected]>
Signed-off-by: Sam Mayer <[email protected]>
…est files Signed-off-by: Sam Mayer <[email protected]>
The first describe block used the global agent, leaving pooled connections alive after server.closeAllConnections() sent RST. On macOS, the async RST delivery could surface as ECONNRESET in the next describe block's fetch call. Give each block its own Client and await cleanup to eliminate the race. Signed-off-by: Sam Mayer <[email protected]>
This reverts commit 29ddaeb.
This reverts commit 78d583d.
…ervers The chain limit tests ran concurrently (node:test uses Promise.all within a Suite), so a shared server was unsafe: an aborted connection's async RST delivery on macOS could corrupt the server state for a sibling test. Replace the shared before/after server with a setupChainServer(t) helper that creates an isolated server+client pair per test and binds cleanup to t.after, which is scoped to each individual test context. Also removes the keepalive: false no-op (undici documents this flag as a noop outside of browser context).
2737414 to
5cf144d
Compare
13e6c47 to
02ce816
Compare
|
|
||
| await t.assert.rejects( | ||
| fetch(`http://localhost:${server.address().port}`, { | ||
| fetch(`http://127.0.0.1:${server.address().port}`, { |
There was a problem hiding this comment.
I noticed that Test with Node.js 20 on macos-latest was consistently failing in CI with the error:
[cause]: Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:218:20) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
I was unable to reproduce this locally on my mac, but setting an explicit localhost IP instead of resolving from localhost seemed to resolve the issue. Taking a look at some other open PRs (not using # to avoid a noisy cross-reference), I see that they're failing for what appears to be the same reason:
I have a hunch that the core issue is with how localhost resolves in the CI environment, but that particular change is unrelated to the focus of this PR. I could remove this change or present it as a separate PR, if you'd like.
This relates to...
Relates to #251 and #4833.
Rationale
Adds disconnect guard assertions to unit tests that follow the pattern seen in #4833. This PR adds the guard to additional tests that do not already adopt the pattern, and documents it.
Changes
Disconnect guards
This PR structures tests along these lines:
Fix encoding test (Node 20 + macOS)
I noticed that there were CI issues with
test/fetch/encoding.json Node.js 20 + macOS. As part of this PR, I also changed the chain limit test server fromserver.listen(0, 'listening')to specify127.0.0.1which fixed the test failure'sECONNRESETerror. I also addedflushHeaders()and per-socketsetNoDelay()as seen in #4496.Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
None
Benchmarks
Status