Skip to content

tty: add raw-vt and io raw modes#64140

Open
samuel-williams-shopify wants to merge 1 commit into
nodejs:mainfrom
samuel-williams-shopify:tty-raw-vt-io-mode
Open

tty: add raw-vt and io raw modes#64140
samuel-williams-shopify wants to merge 1 commit into
nodejs:mainfrom
samuel-williams-shopify:tty-raw-vt-io-mode

Conversation

@samuel-williams-shopify

Copy link
Copy Markdown

Adds string raw-mode selection to tty.ReadStream#setRawMode():

  • setRawMode(true) keeps the existing behavior.
  • setRawMode('raw-vt') explicitly selects the existing Node raw mode backed by libuv UV_TTY_MODE_RAW_VT.
  • setRawMode('io') selects libuv UV_TTY_MODE_IO for binary-safe I/O mode on Unix.
  • readStream.rawMode exposes the exact current mode while readStream.isRaw remains boolean for compatibility.

This is intended to address the output-processing distinction discussed in #63059 and follows libuv's existing UV_TTY_MODE_IO semantics. It preserves the current setRawMode(true) behavior instead of changing it.

Refs: #63059
Refs: libuv/libuv#32

Local verification:

  • git diff --check passes.
  • A full local build could not complete because macOS killed Cargo build-script-build executables as untrusted on this machine; relying on CI for the native build and pseudo-tty test run.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. tty Issues and PRs related to the tty subsystem. labels Jun 26, 2026
@samuel-williams-shopify samuel-williams-shopify force-pushed the tty-raw-vt-io-mode branch 3 times, most recently from c2211c4 to f8d0128 Compare June 26, 2026 04:20
Comment thread doc/api/tty.md
raw device. If `false`, configures the `tty.ReadStream` to operate in its
default mode. The `readStream.isRaw` property will be set to the resulting
mode.
* `mode` {boolean|string} If `true` or `'raw-vt'`, configures the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not use 'raw-vt' as a name and instead just use 'raw'. UV_TTY_MODE_RAW_VT is what UV_TTY_MODE_RAW should probably have been all along – the only reason they aren't merged (yet) into a single constant is backwards compatibility expectations in libuv.

Comment thread lib/tty.js
ttyMode = UV_TTY_MODE_IO;
} else if (rawMode === 'raw-vt') {
ttyMode = UV_TTY_MODE_RAW_VT;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reject invalid/unrecognized values here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. tty Issues and PRs related to the tty subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants