Title: short body race condition in http parsing · Issue #42276 · nodejs/node · GitHub
Open Graph Title: short body race condition in http parsing · Issue #42276 · nodejs/node
X Title: short body race condition in http parsing · Issue #42276 · nodejs/node
Description: Version v16.14.0 Platform Linux chad1 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Subsystem http net.Socket streams What steps will reproduce the bug? In this gist: https://gist.git...
Open Graph Description: Version v16.14.0 Platform Linux chad1 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Subsystem http net.Socket streams What steps will reproduce...
X Description: Version v16.14.0 Platform Linux chad1 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Subsystem http net.Socket streams What steps will reproduce...
Opengraph URL: https://github.com/nodejs/node/issues/42276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"short body race condition in http parsing","articleBody":"### Version\n\nv16.14.0\n\n### Platform\n\nLinux chad1 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux\n\n### Subsystem\n\nhttp net.Socket streams\n\n### What steps will reproduce the bug?\n\nIn this gist: https://gist.github.com/chad3814/b1f927c5cabae86fb2733f1ab37d6bfd\r\nthere are two files, `listener.mjs` and `putter.mjs`. If you run `listener.mjs` and then in another shell run `putter.mjs` you'll see that it saves an empty, zero byte file. Then if you remark the `await sleep(10);` on line 12 on `listener.mjs` and run them again, you'll see that it writes out the file on the first pass through the loop, but on the next pass an `ECONNRESET` is thrown.\n\n### How often does it reproduce? Is there a required condition?\n\nHappens every time as discussed above\n\n### What is the expected behavior?\n\nWhat it looks like to me is when the body of an http message is short, the header and body don't break the high water mark, so it's all read in at once and saved in the buffer list. The problem is triggered by the remote end not waiting for a response from the server and just closing the connection (which is allowed afaik by the http spec). I can understand an `ECONNRESET` being thrown, but we should be able to read the data from the body. Or maybe the error should be thrown if we/when we write to the response object? Either way, we need to reliably read the data using node 16 like we did with node 14.\n\n### What do you see instead?\n\nI see this problem in our production code because `ffmpeg` does the same sort of http call as in `putter.mjs`, where it pushes all the data and then closes the connection without waiting for a response. This all worked in node 14 using `.pipe()`s but with node 16 and pipes we're seeing the two issues above at different times.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/chad3814","@type":"Person","name":"chad3814"},"datePublished":"2022-03-10T00:40:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/42276/node/issues/42276"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4e402e41-c4e9-01da-7281-e6604b7252d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD20:1BE70D:39E0A1:4E259A:6A4D21DF |
| html-safe-nonce | 151d5324b59c6488c2519e185544ba30c556ec1676e00fb0d61bea0c3d515988 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDIwOjFCRTcwRDozOUUwQTE6NEUyNTlBOjZBNEQyMURGIiwidmlzaXRvcl9pZCI6IjU5MTQwNDE1Nzg5MTgwNjA1MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 79097184a438a4c589739a772f7e93cdf8d1dfb8d277e23ef4e4d82965c0f7ad |
| hovercard-subject-tag | issue:1164600158 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/42276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d916eea53b8d09edd6781a87208e2bcc9217e250459626080fce13adfca18388/nodejs/node/issues/42276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d916eea53b8d09edd6781a87208e2bcc9217e250459626080fce13adfca18388/nodejs/node/issues/42276 |
| og:image:alt | Version v16.14.0 Platform Linux chad1 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Subsystem http net.Socket streams What steps will reproduce... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chad3814 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 93f17a978ee60bc4668e1d7b90e6bd2d622261fd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width