René's URL Explorer Experiment


Title: webstreams: writer.closed settles before sink abort() completes when first observed during erroring · Issue #65726 · nodejs/node · GitHub

Open Graph Title: webstreams: writer.closed settles before sink abort() completes when first observed during erroring · Issue #65726 · nodejs/node

X Title: webstreams: writer.closed settles before sink abort() completes when first observed during erroring · Issue #65726 · nodejs/node

Description: Version v24.19.0 through v24.20.0, and current main (v24.18.1 behaves per spec) Platform All (verified on Linux x64) Subsystem webstreams What steps will reproduce the bug? Abort a WritableStream whose sink has a pending operation, and a...

Open Graph Description: Version v24.19.0 through v24.20.0, and current main (v24.18.1 behaves per spec) Platform All (verified on Linux x64) Subsystem webstreams What steps will reproduce the bug? Abort a WritableStream w...

X Description: Version v24.19.0 through v24.20.0, and current main (v24.18.1 behaves per spec) Platform All (verified on Linux x64) Subsystem webstreams What steps will reproduce the bug? Abort a WritableStream w...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"webstreams: writer.closed settles before sink abort() completes when first observed during erroring","articleBody":"### Version\n\nv24.19.0 through v24.20.0, and current `main` (v24.18.1 behaves per spec)\n\n### Platform\n\nAll (verified on Linux x64)\n\n### Subsystem\n\nwebstreams\n\n### What steps will reproduce the bug?\n\nAbort a `WritableStream` whose sink has a pending operation, and access `writer.closed` for the first time *after* erroring has begun but *before* the sink's `abort()` promise settles:\n\n```js\n'use strict';\nconst pending = [];\nfunction deferred() {\n  const d = {};\n  d.promise = new Promise((res, rej) => { d.resolve = res; d.reject = rej; });\n  return d;\n}\n\nconst ws = new WritableStream({\n  write() { const d = deferred(); pending.push(d); return d.promise; },\n  abort() { const d = deferred(); pending.push(d); return d.promise; },\n});\nconst w = ws.getWriter();\n\nw.write('chunk').catch(() => {});\nw.abort(new Error('boom')).catch(() => {});\n\nsetTimeout(async () => {\n  // First access to writer.closed: sink.abort() has NOT settled yet\n  // (its promise is parked in `pending`).\n  const sentinel = {};\n  let state;\n  try {\n    state = (await Promise.race([w.closed, Promise.resolve(sentinel)])) === sentinel\n      ? 'pending' : 'fulfilled';\n  } catch (e) { state = `rejected: ${e.message}`; }\n  console.log(process.version,\n              'writer.closed while sink abort() pending:', state,\n              '| sink abort settled:', pending.length === 0);\n  process.exit(0);\n}, 10);\n```\n\nOutput:\n\n```\nv24.18.1 writer.closed while sink abort() pending: pending  | sink abort settled: false\nv24.19.0 writer.closed while sink abort() pending: rejected: boom | sink abort settled: false\nv24.20.0 writer.closed while sink abort() pending: rejected: boom | sink abort settled: false\n```\n\nNote the divergence only occurs when `writer.closed` is *first* accessed after erroring begins. If the getter was already touched while the stream was `'writable'`, all versions follow spec timing — which makes this easy to miss in tests that eagerly attach `closed` handlers.\n\n### How often does it reproduce? Is there a required condition?\n\nDeterministic. Requires the first access of `writer.closed` to happen in the window where the stream has begun erroring but the sink's `abort()` promise has not settled.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`writer.closed` must remain **pending** until the sink's `abort()` promise settles.\n\nPer the spec, `writer.[[closedPromise]]` is rejected only in [`WritableStreamRejectCloseAndClosedPromiseIfNeeded`](https://streams.spec.whatwg.org/#writable-stream-reject-close-and-closed-promise-if-needed), which [`WritableStreamFinishErroring`](https://streams.spec.whatwg.org/#writable-stream-finish-erroring) invokes only from the *upon fulfillment/rejection* reactions of the promise returned by the sink's `abortAlgorithm`. The state is set to `\"errored\"` earlier in FinishErroring, so \"state is errored\" and \"closedPromise is rejected\" are deliberately not the same instant: user code awaiting `writer.closed` is guaranteed the sink's abort/cleanup has completed. Node ≤ 24.18.1 and the spec reference implementation both behave this way.\n\n### What do you see instead?\n\nOn v24.19.0+ a `writer.closed` first observed in that window comes back **already rejected** (with the stored error), i.e. it settles before the sink's abort/cleanup has finished. Code that uses `await writer.closed.catch(...)` as the \"teardown complete\" signal now proceeds while `abort()` is still running.\n\n### Additional information\n\nCause: v24.19.0's lazy materialization of the writer's `[[closedPromise]]` record (`writerClosedPromise()` in `lib/internal/webstreams/writablestream.js`, introduced in #63876). The lazy derivation maps stream state `'errored'` directly to an already-rejected record:\n\n```js\nswitch (stream[kState].state) {\n  case 'writable':\n  case 'erroring':\n    close = PromiseWithResolvers();\n    break;\n  case 'closed':\n    close = resolvedRecord();\n    break;\n  default: // 'errored' — but the spec sets 'errored' BEFORE the sink abort runs\n    close = rejectedHandledRecord(stream[kState].storedError);\n}\n```\n\nbut the spec reaches state `\"errored\"` while the deferred rejection point (abort settlement) is still in the future, so deriving \"rejected\" from the state alone is incorrect for exactly the FinishErroring-with-pending-abort window.\n\nRelated: on v24.20.0 this same early-materialized record (which has `reject: undefined`) caused an uncaught internal `TypeError: closeCache.reject is not a function` in `writableStreamRejectCloseAndClosedPromiseIfNeeded` when the abort later settled, crashing the process. That crash was fixed on `main` by #64825 (staged for v24.x), but the fix guards the settle call with `isPromisePending()` and leaves the early rejection in place — `writerClosedPromise()` is unchanged on current `main`, so the spec-conformance issue described here survives the crash fix.\n","author":{"url":"https://github.com/trevnorris","@type":"Person","name":"trevnorris"},"datePublished":"2026-09-01T18:55:57Z","url":"https://github.com/nodejs/node/issues/65726"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:15514183-6d56-304f-a040-3162f3c78f20
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9B46:30551B:50AE1:6DF4B:6AED03FB
html-safe-nonce9ee2ec5bbdee34aa4b2bdcd43861330782ae4705a98d4338005a1092159e68a5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjQ2OjMwNTUxQjo1MEFFMTo2REY0Qjo2QUVEMDNGQiIsInZpc2l0b3JfaWQiOiI5NjQyOTY3MTc1Mzc5NjkxNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4747853f22184884ab9e656dd33c5d300e3d769c32ab0e39a378697ea8c656f7
hovercard-subject-tagissue:5315630608
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/65726/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4ef25ed98260a90a42a6f4d9f3041fccdcf021c8d53edead67f4ee79813d07c5/nodejs/node/issues/65726
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4ef25ed98260a90a42a6f4d9f3041fccdcf021c8d53edead67f4ee79813d07c5/nodejs/node/issues/65726
og:image:altVersion v24.19.0 through v24.20.0, and current main (v24.18.1 behaves per spec) Platform All (verified on Linux x64) Subsystem webstreams What steps will reproduce the bug? Abort a WritableStream w...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametrevnorris
hostnamegithub.com
expected-hostnamegithub.com
None21e10c535436b2122cfb44c76dfb4af296e371850fb60de16776f8a64e5c3ed8
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
release302a6d707c3288a5f951258a2fa3e926b8c8f8cf
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/65726#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F65726
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%2F65726
Sign uphttps://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/65726
Reloadhttps://github.com/nodejs/node/issues/65726
Reloadhttps://github.com/nodejs/node/issues/65726
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues654 (654)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65726
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65726
#65727https://github.com/nodejs/node/pull/65727
webstreams: writer.closed settles before sink abort() completes when first observed during erroringhttps://github.com/nodejs/node/issues/65726#top
#65727https://github.com/nodejs/node/pull/65727
https://github.com/trevnorris
trevnorrishttps://github.com/trevnorris
on Sep 1, 2026https://github.com/nodejs/node/issues/65726#issue-5315630608
WritableStreamRejectCloseAndClosedPromiseIfNeededhttps://streams.spec.whatwg.org/#writable-stream-reject-close-and-closed-promise-if-needed
WritableStreamFinishErroringhttps://streams.spec.whatwg.org/#writable-stream-finish-erroring
#63876https://github.com/nodejs/node/pull/63876
#64825https://github.com/nodejs/node/pull/64825
https://github.com/animesh68
animesh68https://github.com/animesh68
on Sep 1, 2026https://github.com/nodejs/node/issues/65726#issuecomment-5499247989
https://github.com/MikeMcC399
MikeMcC399https://github.com/MikeMcC399
on Sep 1, 2026https://github.com/nodejs/node/issues/65726#issuecomment-5499888625
@animesh68https://github.com/animesh68
Guides and FAQs for first-time contributorshttps://github.com/nodejs/node/blob/main/doc/contributing/first-contributions.md
https://github.com/nodejs/node/blob/main/doc/contributing/first-contributions.md#communicating-in-issueshttps://github.com/nodejs/node/blob/main/doc/contributing/first-contributions.md#communicating-in-issues
contribution and automation policieshttps://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
pull request guidehttps://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md
AI use policyhttps://github.com/nodejs/node/blob/HEAD/doc/contributing/ai-guidelines.md
Code of Conducthttps://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md
https://github.com/animesh68
animesh68https://github.com/animesh68
on Sep 2, 2026https://github.com/nodejs/node/issues/65726#issuecomment-5504051740
@MikeMcC399https://github.com/MikeMcC399
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#65727https://github.com/nodejs/node/pull/65727
on Sep 12, 2026https://github.com/nodejs/node/issues/65726#event-31018757545
nodejs-github-bothttps://github.com/nodejs-github-bot
on Sep 12, 2026https://github.com/nodejs/node/issues/65726#event-31018757550
stream: reject closed only after sink abort settleshttps://github.com/nodejs/node/commit/50b355ec044a2d8f45f7b4536fb8fa0e9090bee5
50b355ehttps://github.com/nodejs/node/commit/50b355ec044a2d8f45f7b4536fb8fa0e9090bee5
aduh95https://github.com/aduh95
on Sep 16, 2026https://github.com/nodejs/node/issues/65726#event-31270403796
stream: reject closed only after sink abort settleshttps://github.com/nodejs/node/commit/898cd55bdfcd6def5500cf3f12aecbcbbab8c298
898cd55https://github.com/nodejs/node/commit/898cd55bdfcd6def5500cf3f12aecbcbbab8c298
stream: reject closed only after sink abort settleshttps://github.com/nodejs/node/commit/db19499b1b15aa5bc808bf412152ffc5683fab54
db19499https://github.com/nodejs/node/commit/db19499b1b15aa5bc808bf412152ffc5683fab54
stream: reject closed only after sink abort settleshttps://github.com/nodejs/node/commit/70c141568661840773ff243db4feee2038a9a46e
70c1415https://github.com/nodejs/node/commit/70c141568661840773ff243db4feee2038a9a46e
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/65726
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65726
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.