fix: guard inquirer readline pause() for Node 24 compatibility (ERR_USE_AFTER_CLOSE)#14958
Draft
sarayev wants to merge 1 commit into
Draft
fix: guard inquirer readline pause() for Node 24 compatibility (ERR_USE_AFTER_CLOSE)#14958sarayev wants to merge 1 commit into
sarayev wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Node 24 changed readline behavior so that calling
rl.pause()on an already-closed readline interface throwsERR_USE_AFTER_CLOSE(it was a silent no-op on Node <= 22). inquirer 7.3.3'slib/ui/baseUI.jsclose()callsthis.rl.output.end()immediately followed bythis.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 innode_modules/inquirer/lib/ui/baseUI.js:Delivered via patch-package so the guard is applied both on normal npm/yarn installs (root
postinstallnow runspatch-package) and when the CLI is bundled into thepkgbinary.Why patch-package (not an upgrade)
@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
patches/inquirer+7.3.3.patchguardingpause().package.json:postinstall→"husky install && patch-package"; addpatch-package: ^8.0.0devDependency.yarn.lockupdated for the new devDependency.