Skip to content

fix: convert node readable to web stream in honoWrapper#2315

Merged
alexander-akait merged 4 commits intomainfrom
claude/investigate-readable-stream-error-coFd9
May 7, 2026
Merged

fix: convert node readable to web stream in honoWrapper#2315
alexander-akait merged 4 commits intomainfrom
claude/investigate-readable-stream-error-coFd9

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Wrap the Node fs.ReadStream in a Web ReadableStream we control before
handing it to Hono. This routes the response through @hono/node-server's
responseViaCache fast path (writeFromReadableStream) and bypasses Node's
internal Readable.toWeb adapter, whose late error/close propagation
caused intermittent "TypeError: Invalid state: ReadableStream already
closed" on Windows + Node 20.

All controller transitions are guarded so duplicate end/error events
from the underlying fs stream cannot crash the Web stream controller.

claude added 2 commits May 6, 2026 12:19
Wrap the Node fs.ReadStream in a Web ReadableStream we control before
handing it to Hono. This routes the response through @hono/node-server's
responseViaCache fast path (writeFromReadableStream) and bypasses Node's
internal Readable.toWeb adapter, whose late error/close propagation
caused intermittent "TypeError: Invalid state: ReadableStream already
closed" on Windows + Node 20.

All controller transitions are guarded so duplicate end/error events
from the underlying fs stream cannot crash the Web stream controller.
Keep src/index.js focused on the wrapper logic and put the
node-readable -> web-stream adapter alongside the other stream/response
helpers in src/utils.js.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

⚠️ No Changeset found

Latest commit: 1f530ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 6, 2026

CLA Not Signed

Track the upstream race so we can drop the helper once
honojs/node-server#233 / #299 land and the minimum supported Node
version no longer hits the Readable.toWeb adapter bug.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 73.80952% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.70%. Comparing base (fba9214) to head (1f530ae).

Files with missing lines Patch % Lines
src/utils.js 72.50% 8 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2315      +/-   ##
==========================================
- Coverage   93.54%   92.70%   -0.84%     
==========================================
  Files           3        3              
  Lines         960     1001      +41     
  Branches      302      311       +9     
==========================================
+ Hits          898      928      +30     
- Misses         57       65       +8     
- Partials        5        8       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait alexander-akait merged commit fa09212 into main May 7, 2026
15 of 18 checks passed
@alexander-akait alexander-akait deleted the claude/investigate-readable-stream-error-coFd9 branch May 7, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants