Title: stream: `pipe()` no longer ends the destination when EOF follows a backpressured last chunk (regression in v26.11.0) · Issue #67762 · nodejs/node · GitHub
Open Graph Title: stream: `pipe()` no longer ends the destination when EOF follows a backpressured last chunk (regression in v26.11.0) · Issue #67762 · nodejs/node
X Title: stream: `pipe()` no longer ends the destination when EOF follows a backpressured last chunk (regression in v26.11.0) · Issue #67762 · nodejs/node
Description: Version v26.11.0, v26.12.1, v26.13.1 (works in v26.10.0 and in v20, v22 and v24) Platform Linux 192.168.1.15 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 16:33:25 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux (It must be note...
Open Graph Description: Version v26.11.0, v26.12.1, v26.13.1 (works in v26.10.0 and in v20, v22 and v24) Platform Linux 192.168.1.15 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 16:33:25 UTC 2026 x86_64 ...
X Description: Version v26.11.0, v26.12.1, v26.13.1 (works in v26.10.0 and in v20, v22 and v24) Platform Linux 192.168.1.15 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 16:33:25 UTC 2026 x86_64 ...
Opengraph URL: https://github.com/nodejs/node/issues/67762
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"stream: `pipe()` no longer ends the destination when EOF follows a backpressured last chunk (regression in v26.11.0)","articleBody":"### Version\n\nv26.11.0, v26.12.1, v26.13.1 (works in v26.10.0 and in v20, v22 and v24)\n\n### Platform\n\n```text\nLinux 192.168.1.15 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 16:33:25 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux\n\n(It must be noted this is the Hosts' command. The replication is done inside a Podman Container)\n```\n\n### Subsystem\n\nstream\n\n### What steps will reproduce the bug?\n\n```js\n'use strict';\nconst { Readable, Writable } = require('node:stream');\n\n// Source pushes EOF in a later _read() call than its last chunk.\nconst chunks = [Buffer.alloc(64), Buffer.alloc(64), Buffer.alloc(64)];\nlet i = 0;\nconst src = new Readable({\n highWaterMark: 64,\n read() { this.push(i \u003c chunks.length ? chunks[i++] : null); },\n});\n\n// Destination completes every write except the last one.\nlet n = 0;\nconst dest = new Writable({\n highWaterMark: 1,\n write(chunk, enc, cb) { if (++n \u003c chunks.length) setImmediate(cb); },\n});\n\nlet endCalled = false;\nconst end = dest.end;\ndest.end = function(...args) { endCalled = true; return end.apply(this, args); };\n\nsrc.pipe(dest);\nsetTimeout(() => {\n console.log(`${process.version}: src 'end' emitted: ${src.readableEnded}, dest.end() called: ${endCalled}`);\n}, 100);\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, when both of these hold:\n\n- the source pushes `null` in a `_read()` call after the one that pushed its last chunk, and\n- `dest.write()` returns `false` for that last chunk.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```\nv26.10.0: src 'end' emitted: true, dest.end() called: true\n```\n\nThis is the behavior of v26.10.0 and earlier, including v20, v22 and v24. There, `read()` schedules `endReadable()` once it has hit EOF and the buffer is empty, so `pipe()` calls `dest.end()` without waiting for `'drain'`.\n\n### What do you see instead?\n\n```\nv26.11.0: src 'end' emitted: false, dest.end() called: false\nv26.13.1: src 'end' emitted: false, dest.end() called: false\n```\n\nThe source stays paused with `readableEnded === false` and `_readableState.ended === true`. `'end'` is only emitted if the destination emits another `'drain'`.\n\n### Additional information\n\n## Additional information\n\nBisected across the published binaries: v26.10.0 is good and v26.11.0 is bad. The relevant change is the new `flowSync()` fast path in `lib/internal/streams/readable.js`. When `_read()` pushes EOF while `flowSync()` is delivering the last chunk, nothing schedules `endReadable()`, whereas the general `read()` path does (`if (nOrig !== n && (state[kState] & kEnded) !== 0) endReadable(this);`).\n\n**Real-world impact:** `@azure/storage-blob`'s `BuffersStream` has exactly this shape, and `node-fetch` 2.x sends request bodies with `body.pipe(req)`. Since v26.11.0, uploads through that stack (for example `actions/upload-artifact`-style clients) can leave a request that never calls `req.end()`. Combined with #YYYYY (the HTTP client drops the socket `'drain'` once the response is complete), the upload step finishes its work and the process then never exits. We saw this in CI over HTTPS, in about 7 of 8 runs uploading a ~180 MB artifact in 8 MiB blocks.\n\n## AI Disclaimer\n\nThis report was made almost entirely with an AI. With the exception of this precise disclaimer.\nIn particular, this was a bug I found in production for our local infrastructure, where CI runs in a self-hosted Forgejo, and a Forgejo Runner, suddenly hung when using forgejo/upload-artifacts@v4 and @v5 with a ~200MB artifact, despite everything working with @v3, and in earlier versions of node.\n\nFor now we are reverting to @v3, but I am obviously notifying the maintainers of the forgejo runner so this can be worked around upstream.\n\nThe AI agent has made a patch that schedules `endReadable()` in `flowSync()` under the same condition as `read()`, with a test.\n\nI don't post a PR, because the AI contribution guidelines specify that the user proposing a PR must fully understand the changes, which I don't yet fully. Thus I post the patch and other relevant files, so the maintainers can check its accuracy, and maybe implement their own patch/test if needed\n\nI am open to any other data that might be needed to clarify the situation, to the best of my ability.\n\nFound at the same time as issue #67763\n\n[0001-stream-emit-end-after-backpressured-last-pipe-chunk.patch](https://github.com/user-attachments/files/35373833/0001-stream-emit-end-after-backpressured-last-pipe-chunk.patch)","author":{"url":"https://github.com/AZMCode","@type":"Person","name":"AZMCode"},"datePublished":"2026-11-24T20:28:45Z","url":"https://github.com/nodejs/node/issues/67762"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:9aab2c97-8287-766f-0e06-99385bc8795b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A09A:14227A:3592B3:4816F7:6B06199E |
| html-safe-nonce | fc0298c983bca3fca17efc66dd156af49953fd8f1f33669724d8c284380e5e20 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDlBOjE0MjI3QTozNTkyQjM6NDgxNkY3OjZCMDYxOTlFIiwidmlzaXRvcl9pZCI6Ijc3MzkwODI3MzkwMjYzNjg5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80f9faf88228d3af1f1401c12c663f3942feac9a232cb2b7a74d9e3c59a90a5a |
| hovercard-subject-tag | issue:6590780383 |
| 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/67762/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f19c6855b5c02e87f91ebe48aef4bf5684e6c22ebf5d7129dbb18927e6482f09/nodejs/node/issues/67762 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f19c6855b5c02e87f91ebe48aef4bf5684e6c22ebf5d7129dbb18927e6482f09/nodejs/node/issues/67762 |
| og:image:alt | Version v26.11.0, v26.12.1, v26.13.1 (works in v26.10.0 and in v20, v22 and v24) Platform Linux 192.168.1.15 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 16:33:25 UTC 2026 x86_64 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AZMCode |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| 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 | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width