Title: Stream not emitting end after removeListener · Issue #9002 · nodejs/node · GitHub
Open Graph Title: Stream not emitting end after removeListener · Issue #9002 · nodejs/node
X Title: Stream not emitting end after removeListener · Issue #9002 · nodejs/node
Description: Version: v6.7.0 Platform: Linux david-Latitude-E6440 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Subsystem: stream This program prints "END": const s = new require('stream').PassThrough(); f...
Open Graph Description: Version: v6.7.0 Platform: Linux david-Latitude-E6440 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Subsystem: stream This program prints "END": const s ...
X Description: Version: v6.7.0 Platform: Linux david-Latitude-E6440 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Subsystem: stream This program prints "END"...
Opengraph URL: https://github.com/nodejs/node/issues/9002
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stream not emitting end after removeListener","articleBody":"- **Version**: v6.7.0\n- **Platform**: Linux david-Latitude-E6440 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux\n- **Subsystem**: stream\n\n\u003c!-- Enter your issue details below this comment. -->\n\nThis program prints \"END\":\n\n``` javascript\nconst s = new require('stream').PassThrough();\n\nfunction readable()\n{\n console.log(this.read());\n}\n\ns.end();\n\nsetTimeout(function ()\n{\n s.on('readable', readable);\n s.on('end', function ()\n {\n console.log(\"END\");\n });\n}, 1000);\n```\n\nwhereas this program does not:\n\n``` javascript\nconst s = new require('stream').PassThrough();\n\nfunction readable()\n{\n console.log(this.read());\n}\n\ns.on('readable', readable);\ns.removeListener('readable', readable);\n\ns.end();\n\nsetTimeout(function ()\n{\n s.on('end', function ()\n {\n console.log(\"END\");\n });\n}, 1000);\n```\n\nThe only difference is that a `readable` listener is added _and then removed_ before the stream is ended.\n\nMy question is whether the behaviour should be the same, given that there is no `readable` listener in both cases when the stream is ended.\n\nI can see in the code why: At https://github.com/nodejs/node/blob/v6.7.0/lib/_stream_readable.js#L696 `readableListening` is set to `true` but it's never reset to `false` if all `readable` listeners are removed.\n\nBefore making any changes however, I'd like to ask whether this is intended behaviour?\n","author":{"url":"https://github.com/davedoesdev","@type":"Person","name":"davedoesdev"},"datePublished":"2016-10-10T07:43:22Z","url":"https://github.com/nodejs/node/issues/9002"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:1ac6991e-0260-481b-1a12-583b13d7241d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBE0:13FB37:138C16A:1A670BD:6B03FCB4 |
| html-safe-nonce | a1b825777447c23ec6758b9c4742e7a071b5e9251f5f50683054cd2815a62c8c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkUwOjEzRkIzNzoxMzhDMTZBOjFBNjcwQkQ6NkIwM0ZDQjQiLCJ2aXNpdG9yX2lkIjoiNzU0NTU1NzkwNzg3NDc3NDE5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c4ef453cc952dd19bbb61292d59b08ee0672670448515e530a2c57385b2900b0 |
| hovercard-subject-tag | issue:181952972 |
| 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/9002/issue_layout |
| twitter:image | https://opengraph.githubassets.com/382ede9c3e28a04fd22e8511706ba31adf2c649ec046e71ee8d20b8f2ab3790d/nodejs/node/issues/9002 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/382ede9c3e28a04fd22e8511706ba31adf2c649ec046e71ee8d20b8f2ab3790d/nodejs/node/issues/9002 |
| og:image:alt | Version: v6.7.0 Platform: Linux david-Latitude-E6440 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Subsystem: stream This program prints "END": const s ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | davedoesdev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width