Description
The CLI installs hidden SIGINT and SIGTERM relay listeners and wraps process.listenerCount() so those internal listeners are not visible. The wrapper currently subtracts one from every count for those signals, including the listenerCount(eventName, listener) overload and cases where the hidden listener has already been removed.
Reproduction
const handler = () => {};
process.on('SIGINT', handler);
setTimeout(() => {
console.log(process.listenerCount('SIGINT', handler));
process.removeAllListeners('SIGINT');
console.log(process.listenerCount('SIGINT'));
}, 100);
With Node v24.18.0:
With the current tsx master (5828ffe):
Expected behavior
Specific user-listener counts should match Node, aggregate counts should never become negative, and the internal relay listener should remain hidden while it is installed.
Description
The CLI installs hidden
SIGINTandSIGTERMrelay listeners and wrapsprocess.listenerCount()so those internal listeners are not visible. The wrapper currently subtracts one from every count for those signals, including thelistenerCount(eventName, listener)overload and cases where the hidden listener has already been removed.Reproduction
With Node v24.18.0:
With the current
tsxmaster (5828ffe):Expected behavior
Specific user-listener counts should match Node, aggregate counts should never become negative, and the internal relay listener should remain hidden while it is installed.