Skip to content

fix: guard inquirer readline pause() for Node 24 compatibility (ERR_USE_AFTER_CLOSE)#14958

Draft
sarayev wants to merge 1 commit into
devfrom
fix/node24-inquirer-pause-guard
Draft

fix: guard inquirer readline pause() for Node 24 compatibility (ERR_USE_AFTER_CLOSE)#14958
sarayev wants to merge 1 commit into
devfrom
fix/node24-inquirer-pause-guard

Conversation

@sarayev

@sarayev sarayev commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Node 24 changed readline behavior so that calling rl.pause() on an already-closed readline interface throws ERR_USE_AFTER_CLOSE (it was a silent no-op on Node <= 22). inquirer 7.3.3's lib/ui/baseUI.js close() calls this.rl.output.end() immediately followed by this.rl.pause(), tripping this error and crashing the Gen1 CLI on any interactive prompt teardown (e.g. amplify add function).

Reproduced and fixed under Node 24.14.0: unpatched → ERR_USE_AFTER_CLOSE; patched → clean exit 0.

Fix

Guard the pause() call in node_modules/inquirer/lib/ui/baseUI.js:

// Node 24: pause() on an already-closed readline throws ERR_USE_AFTER_CLOSE (no-op on Node <=22)
if (!this.rl.closed) {
  this.rl.pause();
}

Delivered via patch-package so the guard is applied both on normal npm/yarn installs (root postinstall now runs patch-package) and when the CLI is bundled into the pkg binary.

Why patch-package (not an upgrade)

  • inquirer 8.x has the identical bug — bumping to 8 does not help.
  • inquirer 9+ is an ESM-only rewrite (@inquirer/prompts), not a drop-in upgrade for this codebase.

patch-package is therefore the minimal, durable fix.

Impact

Unblocks Gen1 e2e runs on Node 24.

Changes

  • New patches/inquirer+7.3.3.patch guarding pause().
  • Root package.json: postinstall"husky install && patch-package"; add patch-package: ^8.0.0 devDependency.
  • yarn.lock updated for the new devDependency.

…SE_AFTER_CLOSE)

Node 24 changed readline behavior so that calling `rl.pause()` on an
already-closed readline interface throws `ERR_USE_AFTER_CLOSE` (it was a
silent no-op on Node <= 22). inquirer 7.3.3's `lib/ui/baseUI.js` `close()`
calls `this.rl.output.end()` immediately followed by `this.rl.pause()`,
which trips this error and crashes the CLI. Reproduced and fixed under
Node 24.14.0 (unpatched -> ERR_USE_AFTER_CLOSE; patched -> clean exit 0).

The fix guards the call:

    if (!this.rl.closed) {
      this.rl.pause();
    }

Delivered via patch-package so the guard is applied both on normal
npm/yarn installs (postinstall runs `patch-package`) and when the CLI is
bundled into the `pkg` binary. inquirer 8.x has the identical bug, so
bumping to 8 does not help, and inquirer 9+ is an ESM-only rewrite
(`@inquirer/prompts`) that is not a drop-in upgrade for this codebase.
patch-package is therefore the minimal, durable fix.

This unblocks Gen1 e2e runs on Node 24.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant