Repository navigation
fix(ext/node): do not throw error for readline.createInterface outside TTY - #32874
Conversation
Matches Node's behaviour by ignoring `terminal: true` when not inside a TTY. Fixes denoland#32873.
|
Can you please add a test? |
|
@bartlomieju I can try. I found |
|
We can also do something like 'use strict';
const readline = require('readline');
const Stream = require('stream');
const stream = new Stream();
let setRawModeCalled = false;
stream.isTTY = false;
stream.setRawMode = function () {
setRawModeCalled = true;
throw new Error('setRawMode should not be called for non-TTY streams');
};
stream.resume = function () { };
stream.pause = function () { };
const rli = readline.createInterface({
input: stream,
output: stream,
terminal: true
});
rli.close();
console.log(setRawModeCalled);and match it with a fixture falsebut then I still don't know where to place these two files, so any guidance would be appreciated |
If that test tests it, it's enough to add it to |
It does not. There is no test case that covers the bug I fixed. Which is why I'm wondering how and where to place a new test, and how to run it correctly. I can't find any documentation about this, nor do I find existing tests that cover edge cases not contained in Node's test suite. |
|
Suggestion from Claude: |
|
@bartlomieju done, please TAL |
|
Oh I just saw your comment. Glad that the LLM agrees with my repro, but that still does not tell me where to place that test. |
|
Anywhere in |
|
Ahhhh right, that was the info I'm missing, thank you! I'll remove my test again and add a proper one there. Thanks! |
@bartlomieju how should we move forward here? |
The readline [kSetRawMode] should match Node.js and only check if setRawMode is a function (not check isTTY). The real issue is that Deno's process.stdin.setRawMode is always defined (unlike Node where it only exists on TTY stdin), so it needs to guard against calling Deno.stdin.setRaw() on non-TTY streams. This fixes the original ENOTTY error while keeping the node_compat test-readline-set-raw-mode.js passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I pushed a fix. Here's the analysis: Root cause: The problem isn't in readline's The fix (277fbc3):
This way both the original bug (#32873) and the node_compat test pass. |
|
Sure, that works! |
Matches Node's behaviour by ignoring
terminal: truewhen not inside a TTY.Fixes #32873.