Regression bug with clear reproduction steps and proposed fix.
The issue is a regression in the `readline` module since Node v24.2.0, causing a crash when `this.input` is accessed before initialization. A fix involving reordering initialization and adding a regression test has been proposed, but the contributor faced network/build issues, leaving it for others to complete.
v24.13.0
Darwin robhogan-mac 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041 arm64
readline
// readline-repro.js
const readline = require('readline');
const {Readable} = require('stream');
const input = Readable.from([]);
input.onHistoryFileLoaded = () => 'oops';
readline.createInterface(input);
node ./readline-repro.js
Always
Prior to Node v24.2.0, this did not crash
node readline-repro.js
node:internal/readline/interface:571
this.input.pause();
^
TypeError: Cannot read properties of undefined (reading 'pause')
at Interface.pause (node:internal/readline/interface:571:16)
at ReplHistory.initialize (node:internal/repl/history:111:20)
at Interface.setupHistoryManager (node:internal/readline/interface:392:27)
at Interface.InterfaceConstructor (node:internal/readline/interface:218:8)
at new Interface (node:readline:115:3)
at Object.createInterface (node:readline:212:10)
at Object.<anonymous> (/private/tmp/readline-repro.js:6:21)
at Module._compile (node:internal/modules/cjs/loader:1734:14)
at Object..js (node:internal/modules/cjs/loader:1899:10)
at Module.load (node:internal/modules/cjs/loader:1469:32)
Node.js v24.2.0
The example is contrived (what are we doing assigning onHistoryFileLoaded anyway?) but we hit this in the wild in a Node.js update when passing jest.mock() as the input. Rightly or wrongly, jest-mock by default uses a proxy object to create properties as mock functions on access.
So a more real-world issue would be:
// readline-test.js
const readline = require('readline');
readline.createInterface(jest
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!