René's URL Explorer Experiment


Title: Recent behavior change of buffered write callbacks · Issue #31317 · nodejs/node · GitHub

Open Graph Title: Recent behavior change of buffered write callbacks · Issue #31317 · nodejs/node

X Title: Recent behavior change of buffered write callbacks · Issue #31317 · nodejs/node

Description: As requested by @mcollina in #31179 (comment) I'm opening this issue to discuss the possibility of reverting a recent behavior change of writable streams. writable.write() takes an optional callback which, quoting the documentation, is a...

Open Graph Description: As requested by @mcollina in #31179 (comment) I'm opening this issue to discuss the possibility of reverting a recent behavior change of writable streams. writable.write() takes an optional callbac...

X Description: As requested by @mcollina in #31179 (comment) I'm opening this issue to discuss the possibility of reverting a recent behavior change of writable streams. writable.write() takes an optional cal...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recent behavior change of buffered write callbacks","articleBody":"As requested by @mcollina in https://github.com/nodejs/node/pull/31179#issuecomment-572183520 I'm opening this issue to discuss the possibility of reverting a recent behavior change of writable streams.\r\n\r\n[writable.write()](https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback) takes an optional callback which, quoting the documentation, is a\r\n\r\n\u003e Callback for when this chunk of data is flushed\r\n\r\nThe documentation further clarifies the callback behavior as follows:\r\n\r\n\u003e The `writable.write()` method writes some data to the stream, and calls the\r\n\u003e supplied `callback` once the data has been fully handled. If an error occurs,\r\n\u003e the callback _may or may not_ be called with the error as its first argument.\r\n\u003e To reliably detect write errors, add a listener for the `'error'` event. If\r\n\u003e callback is called with an error, it will be called before the `'error'` event\r\n\u003e is emitted.\r\n\r\nThis is quite accurate and inline with the actual implementation. There can only be a single write at time so if `writable.write()` is called while a write is in progress that write is buffered. If the stream errors or is destroyed the callbacks of buffered writes are not called.\r\n\r\nIn https://github.com/nodejs/node/pull/29028 and then in https://github.com/nodejs/node/pull/30596 this behavior was changed to call the callbacks of buffered writes with an error.\r\n\r\nIn my opinion this change was not need or better not justified by a specific issue. From what I've gathered (correct me if I am wrong) the main reason behind the change was that code like this\r\n\r\n```js\r\nawait for (const chunk of src) {\r\n  new Promise(function(resolve, reject) {\r\n    dst.write(chunk, err =\u003e err ? reject(err) : resolve());\r\n  });\r\n}\r\n```\r\n\r\ncould result in a promise that is never settled, but the destination stream in the example does not buffer writes so the callback is always called.\r\n\r\nI think this change creates more problems than it solves:\r\n\r\n- Not all callbacks must be called. A lot of callbacks are only called in response of a specific event / operation. If that event or operation never occurred its associated callback should not be called. This depends on case-by-case basis. In this specific case if the callback is called it makes me think that buffered writes are attempted even after a stream errors or is destroyed and this is not true even after https://github.com/nodejs/node/pull/30596.\r\n- AFAIK no issues have been created? about buffered write callbacks not being called on error in all these years so I think the original behavior is not broken.\r\n- There are some side effects like https://github.com/nodejs/node/issues/30841 or https://github.com/nodejs/node/pull/31179#issuecomment-570890897.\r\n- It is hard to adapt user land code to this new behavior. For example `net.Socket` buffered write callbacks are now called with an error if a write error occurs. Doing the same on Node.js \u003c 13 will be hard and hacky for userland libs. They should wait until Node.js 12 goes EOL to have the same behavior across all supported Node.js versions.\r\n\r\nRefs: https://github.com/nodejs/node/pull/29028\r\nRefs: https://github.com/nodejs/node/pull/30596\r\nRefs: https://github.com/nodejs/node/pull/31179\r\n","author":{"url":"https://github.com/lpinca","@type":"Person","name":"lpinca"},"datePublished":"2020-01-11T15:58:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/31317/node/issues/31317"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a1172aff-5549-550e-b1d5-10d63915e052
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEC3C:1F16:66531DE:9175878:6A50F0A3
html-safe-nonce9fc1d36dbadd3369c02a91ab7d61691e12055fba8a6a12ede3658d92d9d5f940
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzNDOjFGMTY6NjY1MzFERTo5MTc1ODc4OjZBNTBGMEEzIiwidmlzaXRvcl9pZCI6IjEzMzU3NDkwOTg3MjEwNDY2OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfc57522f6821ec7c7716e6838ca5e9ee5f3c275da0ace250e6fd6c7787d25b9d
hovercard-subject-tagissue:548446545
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/31317/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b414a6faf78c4bf4bfb8c24adc44d810a8829334b0876229d5b1f75915cce6f6/nodejs/node/issues/31317
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b414a6faf78c4bf4bfb8c24adc44d810a8829334b0876229d5b1f75915cce6f6/nodejs/node/issues/31317
og:image:altAs requested by @mcollina in #31179 (comment) I'm opening this issue to discuss the possibility of reverting a recent behavior change of writable streams. writable.write() takes an optional callbac...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelpinca
hostnamegithub.com
expected-hostnamegithub.com
None5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838
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
release5ec60191a48933536a90c8a19f47142fcd0d4739
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/31317#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F31317
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/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/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/enterprise/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%2F31317
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/31317
Reloadhttps://github.com/nodejs/node/issues/31317
Reloadhttps://github.com/nodejs/node/issues/31317
Please reload this pagehttps://github.com/nodejs/node/issues/31317
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/31317
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36.1k 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.4k https://github.com/nodejs/node/issues
Pull requests 978 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
Recent behavior change of buffered write callbackshttps://github.com/nodejs/node/issues/31317#top
discussIssues opened for discussions and feedbacks.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22discuss%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/lpinca
lpincahttps://github.com/lpinca
on Jan 11, 2020https://github.com/nodejs/node/issues/31317#issue-548446545
@mcollinahttps://github.com/mcollina
#31179 (comment)https://github.com/nodejs/node/pull/31179#issuecomment-572183520
writable.write()https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
#29028https://github.com/nodejs/node/pull/29028
#30596https://github.com/nodejs/node/pull/30596
stream: invoke buffered write callbacks on error #30596https://github.com/nodejs/node/pull/30596
net: write(cb) not called if destroy():ed before 'connect' #30841https://github.com/nodejs/node/issues/30841
[v13.x backport] stream: invoke buffered write callbacks on error #31179 (comment)https://github.com/nodejs/node/pull/31179#issuecomment-570890897
#29028https://github.com/nodejs/node/pull/29028
#30596https://github.com/nodejs/node/pull/30596
#31179https://github.com/nodejs/node/pull/31179
discussIssues opened for discussions and feedbacks.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22discuss%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.