Skip to content

fix: share useBoxMetrics resize listener via emitLayoutListeners#952

Merged
sindresorhus merged 1 commit into
vadimdemedes:masterfrom
lazopm:master
May 24, 2026
Merged

fix: share useBoxMetrics resize listener via emitLayoutListeners#952
sindresorhus merged 1 commit into
vadimdemedes:masterfrom
lazopm:master

Conversation

@lazopm

@lazopm lazopm commented May 13, 2026

Copy link
Copy Markdown
Contributor

Currently each instance of this hook adds a stdout.on("resize"), quickly hitting the max listeners warning. This errors go through process.emitWarning(), the ink console log patch doesn't catch it and they end up in the terminal output.

A workaround is bumping the max listeners, but I think a better fix is just sharing a single listener. This change simply emits a layout change on resize. Looks like only useBoxMetrics is using addLayoutListeners, so it shouldn't affect any other hooks.

Errors look like this:

MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 resize listeners added to [WriteStream]. 
...
    type: "resize",
   count: 11,

@sindresorhus sindresorhus merged commit 89d43d8 into vadimdemedes:master May 24, 2026
2 checks passed
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