Repository navigation
fix(node/process): make process.stdin.isTTY writable - #31464
Conversation
WalkthroughIntroduces a local getter Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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-brkflag and connect Chrome DevTools tochrome://inspect
Useconsole.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.tsext/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.
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>
7c681b8 to
51caa7c
Compare
There was a problem hiding this comment.
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.isTTYcan be overridden and properly restores the original value. Mirrors the stdout/stderr pattern nicely.Since the PR mentions Playwright specifically sets
isTTYtoundefined, 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
📒 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-brkflag and connect Chrome DevTools tochrome://inspect
Useconsole.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
## 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>
## 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>
Summary
In Node.js,
tty.ReadStreamsetsisTTYas 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
isTTYat runtime. For example, Playwright's test server setsprocess.stdin.isTTY = undefinedto 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
ext/node/polyfills/_process/streams.mjsto add a setter tostdin.isTTYtests/unit_node/process_test.tsRefs