Skip to content

fix(node/process): make process.stdin.isTTY writable - #31464

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
nrako:fix/node-process-stdin-istty
Dec 1, 2025
Merged

bartlomieju merged 1 commit into
denoland:mainfrom
nrako:fix/node-process-stdin-istty

Conversation

@nrako

@nrako nrako commented Nov 30, 2025 •

Copy link
Copy Markdown
Contributor

Summary

In Node.js, tty.ReadStream sets isTTY as a simple instance property (this.isTTY = true), making it naturally writable. Deno's polyfill used a getter-only property definition, preventing assignment.

Some npm packages need to override isTTY at runtime. For example, Playwright's test server sets process.stdin.isTTY = undefined to prevent reporters from blocking on user input during UI mode (microsoft/playwright#37867).

This aligns stdin with the stdout/stderr fix from #26130, ensuring all stdio streams behave consistently with Node.js.

Changes

  • Modified ext/node/polyfills/_process/streams.mjs to add a setter to stdin.isTTY
  • Added test in tests/unit_node/process_test.ts

Refs

@coderabbitai

coderabbitai Bot commented Nov 30, 2025 •

Copy link
Copy Markdown

Walkthrough

Introduces a local getter getStdinIsTTY initialized to io.stdin.isTerminal() and changes process.stdin.isTTY to use getStdinIsTTY() for its getter. A setter is added that replaces the getter with a function returning the assigned value. Tests were updated to assert process.stdin.isTTY matches Deno.stdin.isTerminal(), to override isTTY (via a ts-ignore workaround), verify the change, and restore the original value. No exported/public signatures changed.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately describes the main change: making process.stdin.isTTY writable to match Node.js behavior.
Description check ✅ Passed The description clearly explains the problem (Node.js has writable isTTY, Deno doesn't), provides concrete use cases (Playwright), and references the relevant implementation details and prior related work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant

CLAassistant commented Nov 30, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@nrako
nrako marked this pull request as ready for review November 30, 2025 13:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efa4da8 and 7c681b8.

📒 Files selected for processing (2)
  • ext/node/polyfills/_process/streams.mjs (1 hunks)
  • tests/unit_node/process_test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with --inspect-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit_node/process_test.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: marvinhagemeister
Repo: denoland/deno PR: 31358
File: ext/node/polyfills/process.ts:759-766
Timestamp: 2025-11-20T09:12:20.198Z
Learning: In ext/node/polyfills/process.ts, the process.sourceMapsEnabled property should be defined with enumerable: true to match Node.js behavior (as seen in Node.js source: lib/internal/bootstrap/node.js).
📚 Learning: 2025-11-20T09:12:20.198Z
Learnt from: marvinhagemeister
Repo: denoland/deno PR: 31358
File: ext/node/polyfills/process.ts:759-766
Timestamp: 2025-11-20T09:12:20.198Z
Learning: In ext/node/polyfills/process.ts, the process.sourceMapsEnabled property should be defined with enumerable: true to match Node.js behavior (as seen in Node.js source: lib/internal/bootstrap/node.js).

Applied to files:

  • tests/unit_node/process_test.ts
  • ext/node/polyfills/_process/streams.mjs
🧬 Code graph analysis (1)
ext/node/polyfills/_process/streams.mjs (1)
ext/io/12_io.js (1)
  • stdin (269-269)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: test release linux-aarch64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: lint debug linux-x86_64
  • GitHub Check: build libs
🔇 Additional comments (2)
ext/node/polyfills/_process/streams.mjs (1)

264-274: Correctly implements writable isTTY for stdin.

The getter/setter pattern properly mirrors the stdout/stderr implementation and enables runtime overriding as required by packages like Playwright. Property descriptors are correctly configured.

tests/unit_node/process_test.ts (1)

547-559: Test coverage properly validates the new stdin.isTTY behavior.

The test correctly verifies both reading and writing to process.stdin.isTTY, with proper cleanup in the finally block. Implementation mirrors the existing stdout test pattern.

Comment thread ext/node/polyfills/_process/streams.mjs Resolved
In Node.js, `tty.ReadStream` sets `isTTY` as a simple instance property
(`this.isTTY = true`), making it naturally writable. Deno's polyfill
used a getter-only property definition, preventing assignment.

Some npm packages need to override `isTTY` at runtime. For example,
Playwright's test server sets `process.stdin.isTTY = undefined` to
prevent reporters from blocking on user input during UI mode
(microsoft/playwright#37867).

This aligns stdin with the stdout/stderr fix from denoland#26130, ensuring all
stdio streams behave consistently with Node.js.

Refs:
- https://github.com/nodejs/node/blob/main/lib/tty.js
- https://github.com/microsoft/playwright/blob/main/packages/playwright/src/runner/testServer.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nrako
nrako force-pushed the fix/node-process-stdin-istty branch from 7c681b8 to 51caa7c Compare November 30, 2025 15:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/unit_node/process_test.ts (1)

547-559: Test validates the writability requirement correctly.

The test structure is solid—it verifies that process.stdin.isTTY can be overridden and properly restores the original value. Mirrors the stdout/stderr pattern nicely.

Since the PR mentions Playwright specifically sets isTTY to undefined, you might optionally add a quick assertion for that case:

     try {
       // @ts-ignore isTTY is defined as readonly in types but we allow setting it
       process.stdin.isTTY = !isTTY;
       assertEquals(process.stdin.isTTY, !isTTY);
+      // @ts-ignore test the real-world Playwright use case
+      process.stdin.isTTY = undefined;
+      assertEquals(process.stdin.isTTY, undefined);
     } finally {

Not critical since the core writability is already validated.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c681b8 and 51caa7c.

📒 Files selected for processing (2)
  • ext/node/polyfills/_process/streams.mjs (1 hunks)
  • tests/unit_node/process_test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ext/node/polyfills/_process/streams.mjs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with --inspect-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit_node/process_test.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: marvinhagemeister
Repo: denoland/deno PR: 31358
File: ext/node/polyfills/process.ts:759-766
Timestamp: 2025-11-20T09:12:20.198Z
Learning: In ext/node/polyfills/process.ts, the process.sourceMapsEnabled property should be defined with enumerable: true to match Node.js behavior (as seen in Node.js source: lib/internal/bootstrap/node.js).
📚 Learning: 2025-11-20T09:12:20.198Z
Learnt from: marvinhagemeister
Repo: denoland/deno PR: 31358
File: ext/node/polyfills/process.ts:759-766
Timestamp: 2025-11-20T09:12:20.198Z
Learning: In ext/node/polyfills/process.ts, the process.sourceMapsEnabled property should be defined with enumerable: true to match Node.js behavior (as seen in Node.js source: lib/internal/bootstrap/node.js).

Applied to files:

  • tests/unit_node/process_test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: build libs
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: lint debug linux-x86_64

@bartlomieju bartlomieju left a comment

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.

Cool, thanks!

@bartlomieju
bartlomieju merged commit 42b6c82 into denoland:main Dec 1, 2025
bartlomieju pushed a commit that referenced this pull request Jan 22, 2026
## Summary

In Node.js, `tty.ReadStream` sets `isTTY` as a simple instance property
(`this.isTTY = true`), making it naturally writable. Deno's polyfill
used a getter-only property definition, preventing assignment.

Some npm packages need to override `isTTY` at runtime. For example,
Playwright's test server sets `process.stdin.isTTY = undefined` to
prevent reporters from blocking on user input during UI mode
(microsoft/playwright#37867).

This aligns stdin with the stdout/stderr fix from #26130, ensuring all
stdio streams behave consistently with Node.js.

## Refs
-
https://github.com/nodejs/node/blob/6a1a3ba045ad7d8d46ca443c5bb73b172d6828c3/lib/tty.js#L71
-
https://github.com/microsoft/playwright/blob/3a5a32d26da3c4da1bd45b71c8b9864e1ea480c9/packages/playwright/src/runner/testServer.ts#L257-L266

Co-authored-by: Claude <noreply@anthropic.com>
bartlomieju pushed a commit to bartlomieju/deno that referenced this pull request Jan 26, 2026
## Summary

In Node.js, `tty.ReadStream` sets `isTTY` as a simple instance property
(`this.isTTY = true`), making it naturally writable. Deno's polyfill
used a getter-only property definition, preventing assignment.

Some npm packages need to override `isTTY` at runtime. For example,
Playwright's test server sets `process.stdin.isTTY = undefined` to
prevent reporters from blocking on user input during UI mode
(microsoft/playwright#37867).

This aligns stdin with the stdout/stderr fix from denoland#26130, ensuring all
stdio streams behave consistently with Node.js.

## Refs
-
https://github.com/nodejs/node/blob/6a1a3ba045ad7d8d46ca443c5bb73b172d6828c3/lib/tty.js#L71
-
https://github.com/microsoft/playwright/blob/3a5a32d26da3c4da1bd45b71c8b9864e1ea480c9/packages/playwright/src/runner/testServer.ts#L257-L266

Co-authored-by: Claude <noreply@anthropic.com>
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.

3 participants