Repository navigation
feat(ws): add upgradeTimeout and resolve ws() on handled socket errors - #172
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
… handled socket errors - rename `establishmentTimeout` to `upgradeTimeout` (and `_ws-timeout.ts` to `_upgrade-timeout.ts`) - `ws()` no longer rejects on client socket errors when an `error` listener exists, regardless of `upgradeTimeout` - trim README/AGENTS.md docs, use an options object in the test helper
upgradeTimeout and resolve ws() on handled socket errors
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
+ Coverage 95.03% 95.51% +0.48%
==========================================
Files 8 9 +1
Lines 805 847 +42
Branches 331 336 +5
==========================================
+ Hits 765 809 +44
+ Misses 35 33 -2
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Adds an optional
upgradeTimeouttoproxyUpgradeandProxyServer.ws(), and makesws()settle consistently on client socket errors.upgradeTimeout2147483647ms are capped.code: "ERR_UPSTREAM_UPGRADE_TIMEOUT"andstatusCode: 504is reported.ECONNRESET. This works even while a custom agent has no free socket.ws()settlement (behavior change)Previously, a client socket error during an upgrade always rejected
ws(), even when anerrorlistener had already received it. Nowws()follows the same rule as other errors: with anerrorlistener, the error is emitted and the promise resolves; without one, it rejects. This holds whether or notupgradeTimeoutis set.web()is unchanged.Verification
pnpm test(lint + typecheck + full suite)test/upgrade-timeout.test.tsruns every case against both APIs: silent upstream, queued agent requests (timeout, client close, client error), 1xx/partial headers, a tunnel that outlives the deadline, non-upgrade responses, early upstream errors, and disabled values.test/server.test.ts:ws()settlement on a client socket error, with and without anerrorlistener (fails without the fix).🤖 Generated with AI assistant