Repository navigation
fix: buffer write calls until ephemeral server address is resolved - #915
saiyam-jain-dev wants to merge 1 commit into
Conversation
|
Thanks for picking this up. I wrote #907, so this regression came from my change. I ran this branch (ca792f6) next to 7.3.0 and 7.3.1 on macOS with Node 24.11 and superagent 10.3.0. The repro from #911 fails on 7.3.1 and passes here. So do writes with a delay between them, an explicit encoding, 20 1MB chunks staying in order, One difference I noticed: calling The CI run seems to be waiting on approval, so I thought these results might help in the meantime. |
Fixes #911
Problem
In 7.3.1, ephemeral server binding resolves asynchronously (
app.listen(0, '127.0.0.1')), soserverAddress()temporarily returns a placeholder URL without the ephemeral port. For standard requests,end()formats the real URL once listening before calling Superagent'ssuper.end().However, streaming requests using
.write()invoke Superagent'sthis.request()eagerly, which initializes and cachesthis.reqagainst the placeholder URL (default port 80), resulting inECONNREFUSED.Solution
.write()calls when the ephemeral server address is not yet resolved.listening, or whenend()dispatches, formatthis.urlwith the resolved ephemeral port and flush the buffered write chunks to the request stream.test/issue-fixes.js.