test: add regression test for issue #1373 — default headersTimeout 300s#5467
test: add regression test for issue #1373 — default headersTimeout 300s#5467SNTL84 wants to merge 2 commits into
Conversation
…t 300s Verifies that undici's fetch does not throw HeadersTimeoutError for a server that responds after 35s, confirming the 300e3ms default is in effect and the old 30s behaviour does not regress. Fixes: nodejs#1373
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5467 +/- ##
=======================================
Coverage 93.46% 93.46%
=======================================
Files 110 110
Lines 37115 37115
=======================================
Hits 34690 34690
Misses 2425 2425 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
All CI checks pass and coverage is stable at 93.46%. Would appreciate a maintainer review when you get a chance. 🙏 |
mcollina
left a comment
There was a problem hiding this comment.
The reason why this was never added is because I'm not waiting 30s for a test to pass.
Please use fake timers to implement this.
…lay) Per mcollina's review — replace the real 35s setTimeout with mock.timers so CI completes instantly. Fake clock is fast-forwarded past the old 30s default but under the 300s default, confirming no HeadersTimeoutError. Contributed by Milan Soni (SNTL84) · desidevloper.com
|
Thanks @mcollina — refactored to use Changes made:
Please re-review when you get a chance. 🙏 — Milan Soni (SNTL84) · desidevloper.com |
|
Hi @mcollina — I've addressed your feedback by switching to |
What
Adds a regression test
test/issue-1373-default-timeout.jsthat confirms undici's defaultheadersTimeoutis300e3ms (300s), not the old 30s that caused issues in #1373.Why
Issue #1373 was raised because the default fetch timeout was 30s, causing failures for slow-responding servers. The fix (aligning with Chrome's 300s default) appears to have been applied in:
types/client.d.ts—Default: 300e3 msdocs/docs/api/Client.md—bodyTimeoutdefault300e3However there was no regression test to prevent this from silently reverting. This PR fills that gap.
Test Approach
The test spins up an HTTP server that intentionally delays its response by 35 seconds — beyond the old 30s default but well within the 300s default. A
HeadersTimeoutErrorwould signal a regression.Checklist
Contributed by Milan Soni (SNTL84) · github.com/SNTL84
Open to OSS sponsorship & consulting — AI workflows, automation & full-stack builds · desidevloper.com