Title: stream/iter: falsy cancellation reasons become clean EOF in broadcast and share · Issue #64704 · nodejs/node · GitHub
Open Graph Title: stream/iter: falsy cancellation reasons become clean EOF in broadcast and share · Issue #64704 · nodejs/node
X Title: stream/iter: falsy cancellation reasons become clean EOF in broadcast and share · Issue #64704 · nodejs/node
Description: Version main Platform macOS 26.5.2 Subsystem stream What steps will reproduce the bug? import { broadcast, share, shareSync } from 'node:stream/iter'; const reasons = [0, '', false, null]; async function run(name, make) { for (const reas...
Open Graph Description: Version main Platform macOS 26.5.2 Subsystem stream What steps will reproduce the bug? import { broadcast, share, shareSync } from 'node:stream/iter'; const reasons = [0, '', false, null]; async fu...
X Description: Version main Platform macOS 26.5.2 Subsystem stream What steps will reproduce the bug? import { broadcast, share, shareSync } from 'node:stream/iter'; const reasons = [0, '', false,...
Opengraph URL: https://github.com/nodejs/node/issues/64704
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"stream/iter: falsy cancellation reasons become clean EOF in broadcast and share","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS 26.5.2\n```\n\n### Subsystem\n\nstream\n\n### What steps will reproduce the bug?\n\n```js\nimport { broadcast, share, shareSync } from 'node:stream/iter';\n\nconst reasons = [0, '', false, null];\n\nasync function run(name, make) {\n for (const reason of reasons) {\n const { stream, iterator } = make();\n stream.cancel(reason);\n\n try {\n console.log(name, JSON.stringify(reason), await iterator.next());\n } catch (error) {\n console.log(name, JSON.stringify(reason), 'rejected:', error);\n }\n }\n}\n\nawait run('broadcast', () => {\n const { broadcast: stream } = broadcast();\n return {\n stream,\n iterator: stream.push()[Symbol.asyncIterator](),\n };\n});\n\nawait run('share', () => {\n const stream = share([]);\n return {\n stream,\n iterator: stream.pull()[Symbol.asyncIterator](),\n };\n});\n\nawait run('shareSync', () => {\n const stream = shareSync([]);\n return {\n stream,\n iterator: stream.pull()[Symbol.iterator](),\n };\n});\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nasync `next()` should reject—and sync `next()` should throw—with the exact supplied reason, consistent with [§13.1.4 `Broadcast.cancel()`](https://stream-iter.jasnell.me/#broadcast-cancel) and the corresponding [§13.2.4 `Share.cancel()`](https://stream-iter.jasnell.me/#share-cancel).\n\n> If reason is provided, each consumer sees it as an error; otherwise they see clean completion.\n\n### What do you see instead?\n\n```console\nbroadcast 0 { done: true, value: undefined }\nbroadcast \"\" { done: true, value: undefined }\nbroadcast false { done: true, value: undefined }\nbroadcast null { done: true, value: undefined }\nshare 0 { done: true, value: undefined }\nshare \"\" { done: true, value: undefined }\nshare false { done: true, value: undefined }\nshare null { done: true, value: undefined }\nshareSync 0 { done: true, value: undefined }\nshareSync \"\" { done: true, value: undefined }\nshareSync false { done: true, value: undefined }\nshareSync null { done: true, value: undefined }\n```\n\nevery falsy reason is converted into clean completion for consumers that had not called `next()` before cancellation.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-07-24T04:28:44Z","url":"https://github.com/nodejs/node/issues/64704"}
| 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:83250e75-79b1-3b62-114d-57c21787e0a3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFCA:19E603:913040:BCC414:6AED3AB5 |
| html-safe-nonce | 7f91e204eeeb83ad704c3f786430edb5676b2041fbd13c24a79d107679c42bc7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkNBOjE5RTYwMzo5MTMwNDA6QkNDNDE0OjZBRUQzQUI1IiwidmlzaXRvcl9pZCI6IjYzMDgyMTk3MDQ3OTIzMzcxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d3ea42fc95c2b75f9456f5f9f7e5ff6f043f738f87414532fc1f355d869905a7 |
| hovercard-subject-tag | issue:4965185932 |
| 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/64704/issue_layout |
| twitter:image | https://opengraph.githubassets.com/51147f4a0411b73433872b57563ba7b21fc4bc9a456bcba174e6ff133afb6928/nodejs/node/issues/64704 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/51147f4a0411b73433872b57563ba7b21fc4bc9a456bcba174e6ff133afb6928/nodejs/node/issues/64704 |
| og:image:alt | Version main Platform macOS 26.5.2 Subsystem stream What steps will reproduce the bug? import { broadcast, share, shareSync } from 'node:stream/iter'; const reasons = [0, '', false, null]; async fu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trivikr |
| 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