Title: stream/web: TransformStream race can throw internal "transformAlgorithm is not a function" · Issue #62036 · nodejs/node · GitHub
Open Graph Title: stream/web: TransformStream race can throw internal "transformAlgorithm is not a function" · Issue #62036 · nodejs/node
X Title: stream/web: TransformStream race can throw internal "transformAlgorithm is not a function" · Issue #62036 · nodejs/node
Description: Version v22.9.0 v24.10.0 Platform Darwin MacBook-Air.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:49:24 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8132 arm64 Subsystem stream/web (TransformStream) What steps will reproduc...
Open Graph Description: Version v22.9.0 v24.10.0 Platform Darwin MacBook-Air.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:49:24 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8132 arm64 Subsystem stream/web (T...
X Description: Version v22.9.0 v24.10.0 Platform Darwin MacBook-Air.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:49:24 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8132 arm64 Subsystem stream/web (T...
Opengraph URL: https://github.com/nodejs/node/issues/62036
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"stream/web: TransformStream race can throw internal \"transformAlgorithm is not a function\"","articleBody":"### Version\n\n- v22.9.0\n- v24.10.0\n\n### Platform\n\n```txt\nDarwin MacBook-Air.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:49:24 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8132 arm64\n```\n\n### Subsystem\n\nstream/web (TransformStream)\n\n### What steps will reproduce the bug?\n\nRun:\n\n```js\nimport { TransformStream } from 'node:stream/web';\nimport { setTimeout } from 'node:timers/promises';\n\nconst stream = new TransformStream({\n transform(chunk, controller) {\n controller.enqueue(chunk);\n },\n});\n\n// Important for reproducing this race consistently in my environment.\nawait setTimeout(500);\n\nconst reader = stream.readable.getReader();\nconst writer = stream.writable.getWriter();\n\n// Release backpressure.\nconst pendingRead = reader.read();\n\n// Simulate client disconnect / shutdown.\nconst pendingCancel = reader.cancel(new Error('client disconnected'));\n\n// Late write racing with cancel.\nconst pendingLateWrite = writer.write('late-write');\n\nconst results = await Promise.allSettled([\n pendingRead,\n pendingCancel,\n pendingLateWrite,\n]);\n\nconsole.log(results);\n```\n\n### How often does it reproduce? Is there a required condition?\n\nIntermittent race. In my environment, adding `await setTimeout(...)` before acquiring reader/writer is required for reliable reproduction.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nNo internal implementation TypeError should leak.\n\nMy understanding is that, when shutdown starts concurrently (cancel/abort/close paths), pending or in-flight `write()` operations are expected to settle coherently with stream shutdown semantics (resolve/reject according to stream state), rather than failing because an internal algorithm slot became non-callable.\n\n### What do you see instead?\n\n`pendingLateWrite` can reject with an internal error:\n\n```txt\nTypeError: controller[kState].transformAlgorithm is not a function\n at transformStreamDefaultControllerPerformTransform (node:internal/webstreams/transformstream:527:37)\n at transformStreamDefaultSinkWriteAlgorithm (node:internal/webstreams/transformstream:573:10)\n ...\n```\n\n### Additional information\n\nThis looks like a race where:\n\n1. [`transformStreamDefaultSinkWriteAlgorithm`](https://github.com/nodejs/node/blob/main/lib/internal/webstreams/transformstream.js#L551) has accepted/scheduled a write,\n2. shutdown starts (`readable.cancel()` / `writable.abort()` / close path),\n3. [`transformStreamDefaultControllerClearAlgorithms`](https://github.com/nodejs/node/blob/main/lib/internal/webstreams/transformstream.js#L489) clears `transformAlgorithm`,\n4. pending write continues and reaches [`transformStreamDefaultControllerPerformTransform`](https://github.com/nodejs/node/blob/main/lib/internal/webstreams/transformstream.js#L525).\n\nRelated discussions:\n- https://github.com/whatwg/streams/issues/1296\n- https://github.com/vercel/next.js/discussions/75995\n- https://github.com/sourcebot-dev/sourcebot/issues/170\n\n","author":{"url":"https://github.com/y-hsgw","@type":"Person","name":"y-hsgw"},"datePublished":"2026-02-28T06:30:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/62036/node/issues/62036"}
| 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:5745015b-580a-8581-0ab6-7f992857c25c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3A4:356725:E9F85F:13CD67F:6A4C5E4B |
| html-safe-nonce | 40034c2d1782786dca22464b0e770c2ef694bbc44c45227e5cfa42bc309630c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0E0OjM1NjcyNTpFOUY4NUY6MTNDRDY3Rjo2QTRDNUU0QiIsInZpc2l0b3JfaWQiOiI0OTMyMDYyMTE3NzQ0MTA3MDgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 875b1689a9af885d9023d9ff2697f2578383786ec09614b40ecd7a17232a5d1d |
| hovercard-subject-tag | issue:4004036980 |
| 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/62036/issue_layout |
| twitter:image | https://opengraph.githubassets.com/209a6b967789fe7f61ea3dddd4c74f28f4fee020d53078792a3539c8bffc56a7/nodejs/node/issues/62036 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/209a6b967789fe7f61ea3dddd4c74f28f4fee020d53078792a3539c8bffc56a7/nodejs/node/issues/62036 |
| og:image:alt | Version v22.9.0 v24.10.0 Platform Darwin MacBook-Air.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:49:24 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8132 arm64 Subsystem stream/web (T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | y-hsgw |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| 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 | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width