Title: Missing 'aborted' on IncomingMessage (v16 regression) · Issue #40775 · nodejs/node · GitHub
Open Graph Title: Missing 'aborted' on IncomingMessage (v16 regression) · Issue #40775 · nodejs/node
X Title: Missing 'aborted' on IncomingMessage (v16 regression) · Issue #40775 · nodejs/node
Description: Version v16.13.0 / v17.1.0 Platform Darwin Silmaril.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64 Subsystem http What steps will reproduce the bug? 'use strict'; c...
Open Graph Description: Version v16.13.0 / v17.1.0 Platform Darwin Silmaril.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64 Subsystem http What steps...
X Description: Version v16.13.0 / v17.1.0 Platform Darwin Silmaril.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64 Subsystem http What steps...
Opengraph URL: https://github.com/nodejs/node/issues/40775
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing 'aborted' on IncomingMessage (v16 regression)","articleBody":"### Version\r\n\r\nv16.13.0 / v17.1.0\r\n\r\n### Platform\r\n\r\nDarwin Silmaril.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64\r\n\r\n### Subsystem\r\n\r\nhttp\r\n\r\n### What steps will reproduce the bug?\r\n\r\n```js\r\n'use strict';\r\n\r\nconst http = require('http');\r\n\r\nlet clientReq;\r\nconst server = http.createServer(function (req, res) {\r\n req.on('aborted', function () {\r\n console.log('ABORTED');\r\n server.close();\r\n });\r\n\r\n req.on('end', () => {\r\n console.log('DESTROY');\r\n clientReq.destroy();\r\n });\r\n\r\n req.resume(); // read all client data\r\n});\r\n\r\nserver.listen(0, () => {\r\n clientReq = http.request({\r\n method: 'POST',\r\n port: server.address().port,\r\n headers: { connection: 'keep-alive' }\r\n }, (res) => {\r\n });\r\n\r\n clientReq.on('error', (err) => console.log('CLIENT ERROR', err));\r\n\r\n clientReq.end();\r\n});\r\n```\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\n100%\r\n\r\n### What is the expected behavior?\r\n\r\nScript exits and logs the following (node v14.18.1):\r\n\r\n```\r\nDESTROY\r\nCLIENT ERROR Error: socket hang up\r\n at connResetException (internal/errors.js:639:14)\r\n at Socket.socketCloseListener (_http_client.js:449:25)\r\n at Socket.emit (events.js:412:35)\r\n at TCP.\u003canonymous> (net.js:686:12) {\r\n code: 'ECONNRESET'\r\n}\r\nABORTED\r\n```\r\n\r\n### What do you see instead?\r\n\r\nScript *never* exits and misses the last `ABORTED` line from the log:\r\n\r\n```\r\nDESTROY\r\nCLIENT ERROR Error: socket hang up\r\n at connResetException (node:internal/errors:691:14)\r\n at Socket.socketCloseListener (node:_http_client:420:25)\r\n at Socket.emit (node:events:402:35)\r\n at TCP.\u003canonymous> (node:net:687:12) {\r\n code: 'ECONNRESET'\r\n}\r\n```\r\n\r\n### Additional information\r\n\r\nThis seems to be a fallout for #33035, which had to be reverted in the v15 release line, but now included in v16+. I discovered it while investigating https://github.com/hapijs/hapi/issues/4315.\r\n\r\nEssentially `'close'` is now emitted on `IncomingMessage` as soon as all data has been consumed, regardless of whether the underlying stream is still open (ie. the response is still being delivered). Thus node is clearly violating its own streaming API, since the underlying socket is still very much active, and will occasionally need to signal `'aborted'` on the `req` object.\r\n\r\nI expect the proper solution is to delay the `'close'` event until `res` has also finished. This should also fix related issues, like #38924.\r\n\r\n/cc @dnlup","author":{"url":"https://github.com/kanongil","@type":"Person","name":"kanongil"},"datePublished":"2021-11-10T15:32:11Z","url":"https://github.com/nodejs/node/issues/40775"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:212ed210-f0c1-856e-6168-33de484b6e54 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FD8:3B3F35:8E18D6:BA0A6B:6AED3C68 |
| html-safe-nonce | e61f6c2fa3eb76d9239d20bda4aa2a17bfc13b8d05555d6a73fc8c87dff44e3a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkQ4OjNCM0YzNTo4RTE4RDY6QkEwQTZCOjZBRUQzQzY4IiwidmlzaXRvcl9pZCI6IjUwMzY4Mjc5MjM1NjYxMTU5NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f8e52dd55135d08e39eb30af192acc6bc0c6b612b3e7a2e45310fb5965a9c888 |
| hovercard-subject-tag | issue:1049980189 |
| 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/40775/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c8a9ad3d33d7414818bb4e1de8eba4ef7ac75dce16d4b586b060c501eb15d462/nodejs/node/issues/40775 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8a9ad3d33d7414818bb4e1de8eba4ef7ac75dce16d4b586b060c501eb15d462/nodejs/node/issues/40775 |
| og:image:alt | Version v16.13.0 / v17.1.0 Platform Darwin Silmaril.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64 Subsystem http What steps... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kanongil |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| 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 | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width