René's URL Explorer Experiment


Title: pipe() allow destroying source! · Issue #55010 · nodejs/node · GitHub

Open Graph Title: pipe() allow destroying source! · Issue #55010 · nodejs/node

X Title: pipe() allow destroying source! · Issue #55010 · nodejs/node

Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.

Open Graph Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.

X Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.

Opengraph URL: https://github.com/nodejs/node

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pipe() allow destroying source!","articleBody":"### What is the problem this feature will solve?\r\n\r\nnode 20.15.1. The idea is to pass around a stream without having to track the sources and being able to destroy it. So the transformer kinda starts owning control of end of life of it's source. Example use case: Implemet tail -f and abort after 5 lines. Then reading bytes is the source, and turning into lines is a transformer. The consumer (who wants to find a mysqld ready for connections in the log) should not care about the tail -f implementation.\r\n\r\n```\r\nstream = createSource().pipe(transformer)\r\nstream.destroy()\r\n\r\n```\r\nshould destroy the source, too.\r\nThis doesn't happen.\r\n\r\ncomplete test case\r\n\r\n```\r\n// this file tests that using pipeDestroySource actually destroys\r\n// the reader while standard .pipe() doesn't ?\r\nimport {Readable, Writable, Transform} from \"node:stream\";\r\n\r\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\r\n\r\nexport const pipeDestroySource = (source:  Readable,  destination: Writable) => {\r\n    // unpipe or close might work\r\n    destination.on('unpipe', (e) => { if (e == source) source.destroy()})\r\n    return source.pipe(destination)\r\n}\r\n\r\nexport type OnDestroy = () => void\r\n\r\nclass MyReadStream extends Readable {\r\n\r\n  constructor(private ondestroy: OnDestroy) {\r\n    super({autoDestroy: true});\r\n  }\r\n\r\n  _read() {\r\n        this.push(Buffer.from(\"A\\n\"))\r\n  }\r\n  _destroy(err: any, callback: any) {\r\n        console.log(\"MyReadStream _destroy\");\r\n    this.ondestroy()\r\n    callback(err);\r\n  }\r\n} \r\n\r\n\r\nexport class MyTransform extends Transform {\r\n\r\n  constructor(private ondestroy: OnDestroy) {\r\n    super({objectMode: true, autoDestroy: true});\r\n  }\r\n\r\n  _transform(chunk: Buffer, encoding: string, callback: any) {\r\n        this.push(chunk)\r\n        callback();\r\n  }\r\n\r\n  _destroy(err: any, callback: any){\r\n        console.log('MyTransform _destroy');\r\n        this.ondestroy()\r\n        super._destroy(err, callback)\r\n  }\r\n\r\n}\r\nconst main = async () => {\r\n    const test = async (title: string, pipe: (source: Readable, destination: Writable) => Writable, expectations: boolean[] ) => {\r\n        console.log(`=== test ${title} started`);\r\n        let r_destroy_called = false\r\n        let t_destroy_called = false\r\n        const r = new MyReadStream(() => { r_destroy_called = true})\r\n        const t = new MyTransform(()  => { t_destroy_called = true })\r\n        const s = pipe(r, t)\r\n        s.destroy()\r\n\r\n        // logging won't work because the events actions will be run after this method returned!\r\n        // console.log({r_destroy_called, t_destroy_called});\r\n        console.log(`test ${title} done`);\r\n    }\r\n\r\n    await test(   \"pipe\",\r\n            (s, d) => s.pipe(d),\r\n            [false, true]\r\n        )\r\n\r\n    await sleep(1000)\r\n\r\n    await test(\r\n           \"pipeDestroySource\",\r\n           pipeDestroySource,\r\n           [true, true]\r\n       )\r\n}\r\n\r\nmain().catch((e) => {\r\n    console.log(\"== ERROR uncaught exception  ==\");\r\n    console.log(e);\r\n    process.exit(1)\r\n})\r\n\r\n```\r\n\r\n\r\n### What is the feature you are proposing to solve the problem?\r\n\r\n```\r\nstream = createSource().pipe(transformer, { destroySource: true })\r\nstream.destroy()\r\n```\r\n\r\n### What alternatives have you considered?\r\n\r\nusing this code instead:\r\n```\r\nexport const pipeDestroySource = (source:  Readable,  destination: Writable) => {\r\n    // unpipe or close might work\r\n    destination.on('unpipe', (e) => { if (e == source) source.destroy()})\r\n    return source.pipe(destination)\r\n}\r\n```","author":{"url":"https://github.com/MarcWeber","@type":"Person","name":"MarcWeber"},"datePublished":"2024-09-19T12:38:21Z","url":"https://github.com/nodejs/node/issues/55010"}

react-profiling0
react-import-mapreact,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/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:bd08d169-b9c2-6bad-52a3-0f436165db22
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9DEE:34E7AF:9A67E4:CA7883:6AED3FC8
html-safe-noncee88d6ea365c869dd3fcb48cf8d17fa6f3f263c150674cc91ce8e08377e68db5f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REVFOjM0RTdBRjo5QTY3RTQ6Q0E3ODgzOjZBRUQzRkM4IiwidmlzaXRvcl9pZCI6IjE1Nzg3NTcyNzQ1OTcxNDY1NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbcc7de9590a8431a25ecbf3b58ef0b485a0722b986a99071062df237594fa31d
hovercard-subject-tagrepository:27193779
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/issues/55010
twitter:imagehttps://opengraph.githubassets.com/c98c20307051bad41306fc36e9903183c09244beae86eb8696467effbe10f1d6/nodejs/node
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c98c20307051bad41306fc36e9903183c09244beae86eb8696467effbe10f1d6/nodejs/node
og:image:altNode.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184
turbo-cache-controlno-cache
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec629ad99c254d306375fc8354d04321c2c362236
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/55010#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F55010
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F55010
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/55010
Reloadhttps://github.com/nodejs/node/issues/55010
Reloadhttps://github.com/nodejs/node/issues/55010
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/55010
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/55010
pipe() allow destroying source!https://github.com/nodejs/node/issues/55010#top
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
streamIssues and PRs related to Node.js streams.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stream%22
https://github.com/MarcWeber
MarcWeberhttps://github.com/MarcWeber
on Sep 19, 2024https://github.com/nodejs/node/issues/55010#issue-2536223152
MarcWeberhttps://github.com/MarcWeber
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
on Sep 19, 2024https://github.com/nodejs/node/issues/55010#event-14323457549
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Sep 19, 2024https://github.com/nodejs/node/issues/55010#event-14784552562
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Sep 19, 2024https://github.com/nodejs/node/issues/55010
avivkellerhttps://github.com/avivkeller
streamIssues and PRs related to Node.js streams.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stream%22
on Sep 19, 2024https://github.com/nodejs/node/issues/55010#event-14323770737
https://github.com/avivkeller
avivkellerhttps://github.com/avivkeller
on Sep 23, 2024https://github.com/nodejs/node/issues/55010#issuecomment-2367095454
https://streams.spec.whatwg.orghttps://streams.spec.whatwg.org
https://github.com/mcollina
mcollinahttps://github.com/mcollina
on Sep 23, 2024https://github.com/nodejs/node/issues/55010#issuecomment-2367296929
https://streams.spec.whatwg.orghttps://streams.spec.whatwg.org
https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-optionshttps://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options
mcollinahttps://github.com/mcollina
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 23, 2024https://github.com/nodejs/node/issues/55010#event-14357684458
avivkellerhttps://github.com/avivkeller
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Oct 11, 2024https://github.com/nodejs/node/issues/55010
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/55010
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/55010
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
streamIssues and PRs related to Node.js streams.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stream%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.