Skip to content

fix: resolve MaxListenersExceededWarning on prompt calls#193

Open
shazron wants to merge 3 commits into
masterfrom
fix/max-listeners-warning
Open

fix: resolve MaxListenersExceededWarning on prompt calls#193
shazron wants to merge 3 commits into
masterfrom
fix/max-listeners-warning

Conversation

@shazron

@shazron shazron commented Apr 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Bumps process.stdout/process.stderr max listeners to 20 in prompt.js to prevent the MaxListenersExceededWarning that fires when @inquirer/core pipes a MuteStream to stdout in an oclif environment that already saturates the default 10-listener budget
  • Adds a promptConfirm helper wrapping @inquirer/prompts confirm so callers get a proper (Y/n) UI
  • Switches config:clear from a raw text input (with manual [yN] parsing) to promptConfirm

Test plan

  • aio config clear — should show a (Y/n) confirm prompt with no MaxListenersExceededWarning in output
  • NODE_OPTIONS="--trace-warnings" aio config clear — warning should no longer appear
  • Answer n / Enter → command exits without clearing
  • Answer y → config is cleared
  • aio config clear -f — skips prompt entirely (no regression)
  • aio config set key -i — text input prompt still works normally

🤖 Generated with Claude Code

Bump stdout/stderr max listeners to prevent the Node.js memory-leak
warning triggered when @inquirer/core pipes a MuteStream to process.stdout
in an oclif environment that already saturates the default 10-listener budget.

Also switches config:clear from a raw text input to a proper confirm prompt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shazron

shazron commented Apr 13, 2026

Copy link
Copy Markdown
Member Author

The only annoying thing is, after clearing config, you might get a telemetry prompt when you try to get a key -- but that is existing behavior:

❯ aio config clear -f
❯ aio config get key

      How you use @adobe/aio-cli provides us with important data that we can use
      to make our products better. Please read our guide for more information on
      the data we anonymously collect, and how we use it.
      https://developer.adobe.com/app-builder/docs/guides/telemetry/

? Would you like to allow @adobe/aio-cli to collect anonymous usage data? Yes
Telemetry is on! Nice, you are helping us improve @adobe/aio-cli
If you would like to turn telemetry off, simply run `aio telemetry off

Update clear.js test to mock promptConfirm (boolean) instead of the
old text prompt, add promptConfirm tests to prompt.js test suite, and
fix the jsdoc/no-defaults lint warning on the defaultValue param.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 PR Reviewer

The refactor cleanly replaces a raw text prompt with a typed boolean confirm prompt, improving UX and simplifying the calling code. The workaround for MaxListenersExceededWarning is pragmatic and well-documented. Tests are thorough and correctly updated.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

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.

2 participants