René's URL Explorer Experiment


Title: Pipe to multiple writable streams doesn't throttle and may blow the memory (v4) · Issue #6491 · nodejs/node · GitHub

Open Graph Title: Pipe to multiple writable streams doesn't throttle and may blow the memory (v4) · Issue #6491 · nodejs/node

X Title: Pipe to multiple writable streams doesn't throttle and may blow the memory (v4) · Issue #6491 · nodejs/node

Description: Version: v4.4.3 Platform: Darwin 15.4.0 Darwin Kernel Version 15.4.0 Subsystem: stream Hi See below the code to reproduce and the output. With node v0.10 or >=v5.11 the issue doesn't happen. I think this is the commit that fixed it - #60...

Open Graph Description: Version: v4.4.3 Platform: Darwin 15.4.0 Darwin Kernel Version 15.4.0 Subsystem: stream Hi See below the code to reproduce and the output. With node v0.10 or >=v5.11 the issue doesn't happen. I thin...

X Description: Version: v4.4.3 Platform: Darwin 15.4.0 Darwin Kernel Version 15.4.0 Subsystem: stream Hi See below the code to reproduce and the output. With node v0.10 or >=v5.11 the issue doesn't happen....

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pipe to multiple writable streams doesn't throttle and may blow the memory (v4)","articleBody":"\u003c!--\nThanks for wanting to report an issue you've found in Node.js. Please fill in\nthe template below by replacing the html comments with an appropriate answer.\nIf unsure about something, just do as best as you're able.\n\nversion: usually output of `node -v`\nplatform:  either `uname -a` output, or if Windows, version and 32 or 64-bit.\nsubsystem:  optional -- if known please specify affected core module name.\n\nIt will be much easier for us to fix the issue if a test case that reproduces\nthe problem is provided. Ideally this test case should not have any external\ndependencies. We understand that it is not always possible to reduce your code\nto a small test case, but we would appreciate to have as\nmuch data as possible.\n\nThank you!\n--\u003e\n- **Version**: v4.4.3\n- **Platform**: Darwin 15.4.0 Darwin Kernel Version 15.4.0\n- **Subsystem**: stream\n\n\u003c!-- Enter your issue details below this comment. --\u003e\n\nHi\nSee below the code to reproduce and the output.\nWith node v0.10 or \u003e=v5.11 the issue doesn't happen.\nI think this is the commit that fixed it - https://github.com/nodejs/node/pull/6023\nShould it be backported to v4 LTS?\n\nThe test case is when piping from single readable to multiple writable streams.\nOne writable stream is a realistic one that has some delay to process the data. \nThe other writable stream is used for progress reporting, so calls its callback immediately.\nWith nodejs v4 the behavior is that adding a fast writable pipe will consume the reader completely into memory which can blow the process.\n\nThanks!\nGuy\n\nThe code to reproduce:\n\n```\n'use strict';\n\nvar stream = require('stream');\n\nif (require.main === module) {\n    main();\n}\n\nfunction main() {\n\n    console.log('');\n    console.log('===========');\n    console.log('NO PROGRESS');\n    console.log('===========');\n    test('none', function() {\n\n        console.log('');\n        console.log('=======================');\n        console.log('PROGRESS WITH TRANSFORM');\n        console.log('=======================');\n        test('transform', function() {\n\n            console.log('');\n            console.log('======================');\n            console.log('PROGRESS WITH WRITABLE');\n            console.log('======================');\n            test('writable', function() {});\n        });\n    });\n}\n\nfunction test(progress_mode, callback) {\n    var nr = 0;\n    var nw = 0;\n    var HIDDEN_KEY = 'tralala##';\n    var CHUNK_SIZE = 16 * 1024;\n\n    var input = new stream.Readable({\n        highWaterMark: CHUNK_SIZE\n    });\n    input._read = function() {\n        if (nr \u003e= 20) {\n            console.log('Read: done');\n            this.push(null);\n            return;\n        }\n        // set a special property on the buffer so writer can verify if copied\n        var buf = new Buffer(CHUNK_SIZE);\n        buf[HIDDEN_KEY + nr] = buf;\n        buf.fill(nr % 256);\n        this.push(buf);\n        nr += 1;\n    };\n\n    var output = new stream.Writable();\n    output._write = function(data, encoding, callback) {\n        // check that the buffer has our special property set by the reader\n        if (data[HIDDEN_KEY + nw] !== data) {\n            console.error('DATA GOT COPIED... AAAAAAAAAAAAHHHHH !!!', nw);\n        }\n        // check how much readhead occured\n        var readahead = nr - nw;\n        if (readahead \u003e 3) {\n            console.error('TOO MUCH READAHEAD', readahead);\n        } else {\n            console.log('Readahead', readahead);\n        }\n        nw += 1;\n        // slow down the writes\n        setTimeout(callback, 10);\n    };\n\n    if (progress_mode === 'transform') {\n        var progress_transform = new stream.Transform({\n            highWaterMark: 0\n        });\n        progress_transform._transform = function(data, encoding, callback) {\n            callback(null, data);\n        };\n        input.pipe(progress_transform).pipe(output);\n    } else if (progress_mode === 'writable') {\n        var progress_writable = new stream.Writable({\n            highWaterMark: 0\n        });\n        progress_writable._write = function(data, encoding, callback) {\n            callback();\n        };\n        input.pipe(progress_writable);\n        input.pipe(output);\n    } else {\n        input.pipe(output);\n    }\n\n    output.on('finish', callback);\n}\n```\n\nHere is the output:\n\n```\n$ node progress_stream.js \n\n===========\nNO PROGRESS\n===========\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nReadahead 2\nRead: done\nReadahead 1\n\n=======================\nPROGRESS WITH TRANSFORM\n=======================\nReadahead 2\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nReadahead 3\nRead: done\nReadahead 2\nReadahead 1\n\n======================\nPROGRESS WITH WRITABLE\n======================\nReadahead 2\nRead: done\nTOO MUCH READAHEAD 19\nTOO MUCH READAHEAD 18\nTOO MUCH READAHEAD 17\nTOO MUCH READAHEAD 16\nTOO MUCH READAHEAD 15\nTOO MUCH READAHEAD 14\nTOO MUCH READAHEAD 13\nTOO MUCH READAHEAD 12\nTOO MUCH READAHEAD 11\nTOO MUCH READAHEAD 10\nTOO MUCH READAHEAD 9\nTOO MUCH READAHEAD 8\nTOO MUCH READAHEAD 7\nTOO MUCH READAHEAD 6\nTOO MUCH READAHEAD 5\nTOO MUCH READAHEAD 4\nReadahead 3\nReadahead 2\nReadahead 1\n```\n","author":{"url":"https://github.com/guymguym","@type":"Person","name":"guymguym"},"datePublished":"2016-04-30T20:34:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/6491/node/issues/6491"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fd487c31-cc6b-6c7a-4e0d-7067d9b8008e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBDE8:3FF0AC:92B4AD:C87032:6A4DB8B7
html-safe-nonced1333740c0cd79d3fe28ed5aaeb33b3ce3245507aa5f23a696f6daf5443729d0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREU4OjNGRjBBQzo5MkI0QUQ6Qzg3MDMyOjZBNERCOEI3IiwidmlzaXRvcl9pZCI6IjE2NDI2Nzg1OTMxMTk2NjM5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3a7da3fca9bfd3c8e324d183a19157e20d68892ad43fb408dfd11c8e24f7914e
hovercard-subject-tagissue:152051249
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/6491/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d4e5ef81d2da6ca3bc8e51a5e7799273697b198451a1407fa6b7a45b3f844228/nodejs/node/issues/6491
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d4e5ef81d2da6ca3bc8e51a5e7799273697b198451a1407fa6b7a45b3f844228/nodejs/node/issues/6491
og:image:altVersion: v4.4.3 Platform: Darwin 15.4.0 Darwin Kernel Version 15.4.0 Subsystem: stream Hi See below the code to reproduce and the output. With node v0.10 or >=v5.11 the issue doesn't happen. I thin...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameguymguym
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
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
release32f7b614aca06e6bbd89842b1370df1328264f68
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/6491#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F6491
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F6491
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/6491
Reloadhttps://github.com/nodejs/node/issues/6491
Reloadhttps://github.com/nodejs/node/issues/6491
Please reload this pagehttps://github.com/nodejs/node/issues/6491
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/6491
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.3k https://github.com/nodejs/node/issues
Pull requests 962 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Pipe to multiple writable streams doesn't throttle and may blow the memory (v4)https://github.com/nodejs/node/issues/6491#top
questionIssues that look for answers.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22question%22
streamIssues and PRs related to the stream subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stream%22
https://github.com/guymguym
guymguymhttps://github.com/guymguym
on Apr 30, 2016https://github.com/nodejs/node/issues/6491#issue-152051249
#6023https://github.com/nodejs/node/pull/6023
questionIssues that look for answers.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22question%22
streamIssues and PRs related to the stream subsystem.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.