Repository navigation
fix: wait for the ephemeral server before writing request bodies - #912
Open
codesbysaravana wants to merge 2 commits into
Open
codesbysaravana wants to merge 2 commits into
codesbysaravana wants to merge 2 commits into
Conversation
1 task
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.
Fixes #911.
After #907, the loopback bind resolves asynchronously.
serverAddress()temporarily returns a URL without the ephemeral port, whichend()corrects once the server is listening. Rawwrite()calls Superagent'srequest()earlier and creates a cached request against port 80.This delays raw writes until the server has an address and returns
falsewhile waiting so piped sources pause. Once listening, it resolves the URL, forwards the queued chunks in order, and resumes the source. Later drain events are forwarded because Superagent only forwards the first one. It also resolves the placeholder URL when the first write arrives after listening.Abort, startup-error and close handlers discard queued writes and remove the startup listeners. Existing-server writes still use Superagent directly. The loopback-only binding from #907 remains unchanged; this does not modify the shared-server lifetime work in #910.
Tests
Added 13 regression tests covering:
npm testpasses with 150 tests on Linux under Node 18.20.8, 20.20.2, 22.23.3, 24.21.0 and 26.10.0. This includes the repository lint and coverage run. The streaming tests passed 20 consecutive runs on Node 22.git diff --checkpasses.The supplied
.write()reproduction failed with ECONNREFUSED on unmodified 7.3.1. No dependency or lockfile changes are included.Not tested on macOS or Windows. The fix covers request-body streaming; response piping behavior is outside this patch.