Title: Stream finished does not always work with http incoming message · Issue #38657 · nodejs/node · GitHub
Open Graph Title: Stream finished does not always work with http incoming message · Issue #38657 · nodejs/node
X Title: Stream finished does not always work with http incoming message · Issue #38657 · nodejs/node
Description: Version: v15.12.0 Platform: Darwin Kernel Version 20.3.0 Subsystem: http What steps will reproduce the bug? The stream.finished never resolves or rejects when applied onto a destroyed incoming message like in example below. It finishes f...
Open Graph Description: Version: v15.12.0 Platform: Darwin Kernel Version 20.3.0 Subsystem: http What steps will reproduce the bug? The stream.finished never resolves or rejects when applied onto a destroyed incoming mess...
X Description: Version: v15.12.0 Platform: Darwin Kernel Version 20.3.0 Subsystem: http What steps will reproduce the bug? The stream.finished never resolves or rejects when applied onto a destroyed incoming mess...
Opengraph URL: https://github.com/nodejs/node/issues/38657
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stream finished does not always work with http incoming message","articleBody":"* **Version**: v15.12.0\n* **Platform**: Darwin Kernel Version 20.3.0\n* **Subsystem**: http\n\n### What steps will reproduce the bug?\n\nThe `stream.finished` never resolves or rejects when applied onto a destroyed incoming message like in example below. It finishes for example when applied on a destroyed file stream. Also it finishes when the line with `await new Promise(r => setTimeout(r, 1000));` is commented. This looks really inconsistent.\n\n``` js\nlet http = require(\"http\");\nlet { finished } = require(\"stream/promises\");\n\nlet server = http.createServer(async function(req, res)\n{\n\tfor await (let chunk of req) break;\n\tawait new Promise(r => setTimeout(r, 1000));\n\tconsole.log(\"waiting\");\n\tawait finished(req);\n\tconsole.log(\"sending\");\n\tres.end();\n});\n\n(async function()\n{\n\tawait new Promise(resolve => server.listen(resolve));\n\tlet req = http.request({ port: server.address().port, method: \"post\" }).end(\"abc\");\n\ttry\n\t{\n\t\tlet res = await new Promise((resolve, reject) => req.on(\"response\", resolve).on(\"error\", reject));\n\t\tawait finished(res.resume());\n\t}\n\tcatch(e)\n\t{\n\t\tconsole.log(e);\n\t}\n}());\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways.\n\n### What is the expected behavior?\n\n```\nError: socket hang up\nwaiting\nsending\n```\n\n### What do you see instead?\n\n```\nError: socket hang up\nwaiting\n```\n","author":{"url":"https://github.com/misos1","@type":"Person","name":"misos1"},"datePublished":"2021-05-12T19:46:57Z","url":"https://github.com/nodejs/node/issues/38657"}
| 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:379a32be-f908-cd35-ff99-dfc6312c594f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC30:2BD59E:70C475:990ADE:6AED29D5 |
| html-safe-nonce | 717c3562e20779607c790b80d601b70758c91a99343c4eccce80d4f9d2d6be04 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzMwOjJCRDU5RTo3MEM0NzU6OTkwQURFOjZBRUQyOUQ1IiwidmlzaXRvcl9pZCI6IjYwMjQyNTMzMDQ0ODcwOTQ3NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dd65b5223e6f2a58fe81e148bf18c19ac1f875c1b0abbe3eca9c4faf86b267f8 |
| hovercard-subject-tag | issue:890429515 |
| 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/38657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9227c5d40f4bf2e2dbeb5efa4ea0e73899a00231e8cff7d720229656d64f3d6a/nodejs/node/issues/38657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9227c5d40f4bf2e2dbeb5efa4ea0e73899a00231e8cff7d720229656d64f3d6a/nodejs/node/issues/38657 |
| og:image:alt | Version: v15.12.0 Platform: Darwin Kernel Version 20.3.0 Subsystem: http What steps will reproduce the bug? The stream.finished never resolves or rejects when applied onto a destroyed incoming mess... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | misos1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| 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 | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width