Repository navigation
Conversation
…g an upload When the data backend fails mid-upload, cloudserver sends the error response with the request body only partially read. Node before 22.18.0 / 24.3.0 then never closes the connection (nodejs/node#58178). Cover that the connection is closed after the error response is sent.
Hello fredmnl,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
| await new Promise(resolve => req.once('close', resolve)); | ||
| clearTimeout(deadline); | ||
|
|
||
| assert(Date.now() - start < closeDeadlineMs, `connection still open after ${closeDeadlineMs}ms`); |
There was a problem hiding this comment.
This check depends on timer accuracy. When the deadline timer is what closes the connection, Date.now() - start is about 5000 and can read as 4999: start is taken before req.write, and setTimeout and Date.now() use different clocks. The test would then pass in exactly the regression it is meant to catch. Set a flag in the deadline callback and assert on that instead, e.g. const deadline = setTimeout(() => { timedOut = true; req.destroy(); }, closeDeadlineMs);, then:
| assert(Date.now() - start < closeDeadlineMs, `connection still open after ${closeDeadlineMs}ms`); | |
| assert(!timedOut, `connection still open after ${closeDeadlineMs}ms`); |
Fixes CLDSRV-1119, part of S3C-11764.
When the data backend fails mid-upload (for example sproxyd closing a reused connection), cloudserver sends the error response with the request body only partially read. On node before 22.18.0 / 24.3.0, the body data parsed after the response cancels the keep-alive timer, and nothing ever closes the connection (nodejs/node#58178). The sockets then pile up until cloudserver restarts.
This branch already runs node 22.23.4, which has the fix. This PR adds a unit test, so that a regression, or an image back on an older node, is caught:
S3Server._startServer, with a shortkeepAliveTimeoutto keep the test fast;putstubbed to fail with EPIPE on the first write;It passes on node 22.23.4 (about 1.1 s) and fails on node 22.14.0 ("connection still open after 5000ms").