Skip to content

fix: lazy-load ora spinner to prevent MaxListenersExceededWarning#100

Open
shazron wants to merge 1 commit intomasterfrom
fix/lazy-ora-spinner
Open

fix: lazy-load ora spinner to prevent MaxListenersExceededWarning#100
shazron wants to merge 1 commit intomasterfrom
fix/lazy-ora-spinner

Conversation

@shazron
Copy link
Copy Markdown
Member

@shazron shazron commented Apr 13, 2026

Summary

Fixes #99

  • ora() was called at module load time (const spinner = require('ora')()), causing ora's internal StdinDiscarder to pipe to process.stdout and register an error event listener immediately on require
  • Each time the module was freshly loaded, a new listener was added, eventually triggering MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WriteStream]
  • Replaced the module-level singleton with a lazy getSpinner() getter that creates the ora instance only on first use

Test plan

  • All 172 existing tests pass with 100% coverage
  • cleanStdOut static method continues to work correctly via getSpinner()

🤖 Generated with Claude Code

Calling ora() at module load time caused the ora StdinDiscarder to pipe
to process.stdout immediately, adding an error event listener on every
module load. Move to a lazy getter so the ora instance is only created
on first use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shazron shazron self-assigned this Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

MaxListenersExceededWarning: Possible EventEmitter memory leak detected.

2 participants