fix: login crashes on Node 24 (readline resize event)#14
Conversation
Node 24's readline calls output.on('resize', ...) during construction.
The fake muted output object only implemented write(), causing a TypeError.
Replace with a PassThrough stream that supports all EventEmitter methods.
Greptile SummaryThis PR fixes a crash in Key changes in
Minor issues found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant user as User (stdin)
participant rl as node:readline
participant mt as PassThrough (mutedOutput)
participant stdout as process.stdout
Note over rl,mt: createInterface({ output: mutedOutput })
rl->>mt: output.on('resize', onresize) [Node 24 — was crashing here]
stdout->>mt: onResize() forwards resize events
rl->>mt: write(questionText)
mt->>stdout: data handler — muted=false → pass through
Note over rl: muted = true
rl->>user: rl.question(prompt)
user->>rl: keystrokes echoed to output
rl->>mt: write(echoedChars)
mt-->>stdout: data handler — muted=true, no question text → suppressed
user->>rl: Enter key
rl->>rl: rl.close()
rl->>stdout: removeListener('resize', onResize)
rl->>mt: mutedOutput.destroy()
rl->>stdout: write('\n')
|
| const mutedOutput = new (await import("node:stream")).PassThrough({ | ||
| decodeStrings: false, | ||
| }); |
There was a problem hiding this comment.
Use static import for
node:stream
node:stream is a built-in Node.js module already used statically elsewhere (e.g. node:readline at the top). Using a dynamic await import() for it is inconsistent, slightly harder to read, and can confuse bundlers like esbuild or rollup that tree-shake native imports. A static import at the top of the file is simpler and idiomatic:
| const mutedOutput = new (await import("node:stream")).PassThrough({ | |
| decodeStrings: false, | |
| }); | |
| const mutedOutput = new PassThrough({ | |
| decodeStrings: false, | |
| }); |
And add at the top of the file:
import { PassThrough } from "node:stream";Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Problem
delega logincrashes immediately on Node 24 with:Node 24 readline calls
output.on('resize', onresize)during construction. The existing fake muted output object only implementedwrite(), so it throws.Fix
Replace the plain object with a
PassThroughstream that has all EventEmitter methods. Forward resize events from the real stdout so readline can track terminal width. Clean up listeners on close.Testing
npm run buildpasses