You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deno correctly registers SIGINT and other SIG* signals with process.on('SIGINT') via node:process imports, but the listeners are not appended to process.listeners('SIGINT') return array. This differs from the original Node.js implementation behavior and causes issues with libraries such as signal-exit@3.0.7
Reproduction Steps
importprocessfrom"node:process";process.on('customEvent',()=>console.log('customEvent'))console.log(process.listeners('customEvent'))// outputs [ [Function (anonymous)] ]process.on('SIGINT',()=>console.log('SIGINT'))console.log(process.listeners('SIGINT'))// outputs [], but it should also contain an anonymous function setTimeout(()=>{},10000)
Explanation
Since Deno uses a custom implementation for handling OS Signals, a specific condition was added to the process polyfill to redirect all process.on() calls for SIG* signals to use Deno.addSignalListener(). However, the method responsible for adding the listener to the array is located at super.on() (in the EventEmitter class), which is never called.
Possible Fix
One possible fix would be to add the super.on(event, listener); call right after the Deno.addSignalListener() line, but I am not sure whether this would cause unintended side-effects between Deno and the polyfill.
Thanks for building Deno!
The text was updated successfully, but these errors were encountered:
Some npm libraries like `signal-exit` rely on the length of the listener
array returned by `process.listeners("SIGNT")` to be correct to
function. We weren't tracking `SIG*` events there, which broke those npm
libraries.
Fixes#22892
Some npm libraries like `signal-exit` rely on the length of the listener
array returned by `process.listeners("SIGNT")` to be correct to
function. We weren't tracking `SIG*` events there, which broke those npm
libraries.
Fixes#22892
Some npm libraries like `signal-exit` rely on the length of the listener
array returned by `process.listeners("SIGNT")` to be correct to
function. We weren't tracking `SIG*` events there, which broke those npm
libraries.
Fixes#22892
Version: Deno 1.41.2
Description
Deno correctly registers
SIGINT
and otherSIG*
signals withprocess.on('SIGINT')
vianode:process
imports, but the listeners are not appended toprocess.listeners('SIGINT')
return array. This differs from the original Node.js implementation behavior and causes issues with libraries such assignal-exit@3.0.7
Reproduction Steps
Explanation
Since Deno uses a custom implementation for handling OS Signals, a specific condition was added to the
process
polyfill to redirect allprocess.on()
calls forSIG*
signals to useDeno.addSignalListener()
. However, the method responsible for adding the listener to the array is located atsuper.on()
(in theEventEmitter
class), which is never called.Possible Fix
One possible fix would be to add the
super.on(event, listener);
call right after theDeno.addSignalListener()
line, but I am not sure whether this would cause unintended side-effects between Deno and the polyfill.Thanks for building Deno!
The text was updated successfully, but these errors were encountered: