fix(node:tty): make ReadStream and WriteStream constructors non-throwing#6064
Merged
petebacondarwin merged 2 commits intomainfrom Feb 12, 2026
Merged
fix(node:tty): make ReadStream and WriteStream constructors non-throwing#6064petebacondarwin merged 2 commits intomainfrom
petebacondarwin merged 2 commits intomainfrom
Conversation
8 tasks
jasnell
approved these changes
Feb 12, 2026
Collaborator
jasnell
left a comment
There was a problem hiding this comment.
LGTM once the eslint issues are addressed
Previously, the ReadStream and WriteStream constructors in the node:tty module would throw ERR_METHOD_NOT_IMPLEMENTED, which was a breaking change from the unenv-preset behavior where they are no-ops. This change: - Makes ReadStream and WriteStream constructors succeed and store fd - Sets default properties (isRaw, isTTY, columns, rows) - Changes cursorTo, moveCursor, clearLine, clearScreenDown from throwing to no-op functions that invoke callbacks if provided - Updates tests to verify the new behavior
361cbc1 to
6dd1f25
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6064 +/- ##
==========================================
- Coverage 70.38% 70.37% -0.02%
==========================================
Files 408 408
Lines 108811 108811
Branches 18000 18000
==========================================
- Hits 76591 76575 -16
- Misses 21415 21430 +15
- Partials 10805 10806 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReadStreamandWriteStreamconstructors succeed instead of throwingERR_METHOD_NOT_IMPLEMENTEDcursorTo,moveCursor,clearLine,clearScreenDownmethods from throwing to no-op functions that invoke callbacks if providedMotivation
The previous behavior where constructors threw was a breaking change from how the unenv-preset works (where they are no-ops that can be instantiated). This aligns workerd's TTY implementation with unenv for better compatibility.
Changes
src/node/tty.ts:
ReadStreamconstructor now storesfd, setsisRaw = false,isTTY = falseWriteStreamconstructor now storesfd, setscolumns = 0,rows = 0setRawModenow actually updatesisRawpropertycursorTo,moveCursor,clearLine,clearScreenDownare now no-ops that call callbacks if provided and returnfalsesrc/workerd/api/node/tests/tty-nodejs-test.js: