Skip to content

readline Regression since v24.2.0 Cannot read properties of undefined (reading 'pause') #61526

Description

@robhogan

Version

v24.13.0

Platform

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

Subsystem

readline

What steps will reproduce the bug?

// 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

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Prior to Node v24.2.0, this did not crash

What do you see instead?

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

Additional information

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.mock());

Now crashes.

I root caused this to #58225. Repeating here:

setupHistoryManager is called within InterfaceConstructor, here:

this.setupHistoryManager(input);

Note that's before this.input is assigned, here:

this.input = input;

Which is a problem because setupHistoryManager may call initialize()

setupHistoryManager(options) {
this.historyManager = new ReplHistory(this, options);
if (options.onHistoryFileLoaded) {
this.historyManager.initialize(options.onHistoryFileLoaded);
}

Which tries to call .pause() on the interface's input property (still before it has been assigned)

this[kContext].pause();

CC @puskin

Activity

  1. changed the title [-]`readline` Regression since v24.2.0 Cannot read properties of undefined (reading 'pause')[/-] [+]`readline` Regression since v24.2.0 `Cannot read properties of undefined (reading 'pause')`[/+] on Jan 26, 2026
  2. Zohaibarif69 commented on Jan 26, 2026

    @Zohaibarif69

    I’m working on a fix that reorders the initialization so this.input is assigned before setupHistoryManager() runs, along with a regression test.
    I’ll open a PR shortly.

  3. Zohaibarif69 commented on Jan 26, 2026

    @Zohaibarif69

    I’ve tried setting up a local environment, but due to network and build issues (see screenshot below), I won’t be able to continue testing locally right now. Leaving it for others to pick up.

    ![Terminal output showing network/download issue]
    Image

  4. added
    readlineIssues and PRs related to the built-in readline module.
    on Feb 11, 2026
  5. added a commit that references this issue on Feb 11, 2026
    45e1096
  6. added a commit that references this issue on Feb 21, 2026
    44465a6
  7. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    readlineIssues and PRs related to the built-in readline module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions