Title: Stream not destroyed when piped in Duplex.from() writable · Issue #55077 · nodejs/node · GitHub
Open Graph Title: Stream not destroyed when piped in Duplex.from() writable · Issue #55077 · nodejs/node
X Title: Stream not destroyed when piped in Duplex.from() writable · Issue #55077 · nodejs/node
Description: Version v22.9.0 Platform Darwin MBPM.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030 arm64 Subsystem stream What steps will reproduce the bug? const { Duplex, Readable, p...
Open Graph Description: Version v22.9.0 Platform Darwin MBPM.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030 arm64 Subsystem stream What steps will reprod...
X Description: Version v22.9.0 Platform Darwin MBPM.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030 arm64 Subsystem stream What steps will reprod...
Opengraph URL: https://github.com/nodejs/node/issues/55077
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stream not destroyed when piped in Duplex.from() writable","articleBody":"### Version\n\nv22.9.0\n\n### Platform\n\n```text\nDarwin MBPM.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030 arm64\n```\n\n\n### Subsystem\n\nstream\n\n### What steps will reproduce the bug?\n\n```js\r\nconst { Duplex, Readable, pipeline } = require('node:stream')\r\n\r\npipeline(\r\n Readable.from(\r\n (async function* () {\r\n try {\r\n console.log('Readable stream started')\r\n let i = 32\r\n while (i-- > 0) {\r\n yield Buffer.from('Hello, world!')\r\n console.log('Readable stream resumed')\r\n }\r\n console.log('Readable stream ended')\r\n } catch (err) {\r\n console.log('Readable stream errored', err)\r\n } finally {\r\n console.log('Readable stream destroyed')\r\n }\r\n })(),\r\n { objectMode: false, autoDestroy: true, highWaterMark: 1 }\r\n ),\r\n Duplex.from(async function (asyncGenerator) {\r\n asyncGenerator.return()\r\n }),\r\n (err) => {\r\n if (err) {\r\n console.error('Pipeline failed', err)\r\n } else {\r\n console.log('Pipeline succeeded')\r\n }\r\n }\r\n)\r\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAny code used as `Duplex.from(async function () {})` that does not fully consume the input will prevent the input stream to be properly disposed:\r\n\r\n```js\r\n Duplex.from(async function (asyncGenerator) {\r\n for await (const chunk of asyncGenerator) {\r\n console.log('Writable stream received', chunk)\r\n break\r\n }\r\n })\r\n```\r\n\r\n```js\r\n Duplex.from(async function (asyncGenerator) {\r\n asyncGenerator.retrun()\r\n })\r\n```\r\n\r\n```js\r\n Duplex.from(async function (asyncGenerator) {\r\n // do nothing\r\n })\r\n```\r\n\r\n\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe readable's destroy steps should be called.\n\n### What do you see instead?\n\nThe readable is not destroyed.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/matthieusieben","@type":"Person","name":"matthieusieben"},"datePublished":"2024-09-23T09:39:29Z","url":"https://github.com/nodejs/node/issues/55077"}
| 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:d8d6e089-1dd3-ba45-fdc5-164de1d6823a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDFA:1F55:171FB:739F9:6AED3543 |
| html-safe-nonce | 2d0a23eb8838794095418f8e97f4964a2d5df4946b9f15023c44b2bcb83328e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREZBOjFGNTU6MTcxRkI6NzM5Rjk6NkFFRDM1NDMiLCJ2aXNpdG9yX2lkIjoiMjE0NTk2MjI4NjQ3ODM0MTQ0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 53cab0cd9935e95564fefa83c65874f0f26e6ba8da05eb161aa9c1df2ecfbd3d |
| hovercard-subject-tag | issue:2542092106 |
| 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/55077/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f2ef7a746403d44e2cd15bacfed98f520694266f6542ae145a7a672900ae649/nodejs/node/issues/55077 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f2ef7a746403d44e2cd15bacfed98f520694266f6542ae145a7a672900ae649/nodejs/node/issues/55077 |
| og:image:alt | Version v22.9.0 Platform Darwin MBPM.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030 arm64 Subsystem stream What steps will reprod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matthieusieben |
| 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