Closed nunoguedelha closed 2 years ago
process._getActiveHandles()
and process._getActiveRequests()
to get the pending actions in the Event Loop.=> Moved to #76
Before even adding the listener to the a given closure signal (SIGINT, etc), we execute the following a the end of the main script:
process.listeners(eventName)
),process.removeAllListeners([eventName])
),terminationHandler
(process.once
).After completing terminationHandler
, so, after Subset C...
https://github.com/ami-iit/yarp-openmct/blob/b07deb537ee3513b16bd3a14115c469449d38ba9/iCubTelemVizServer/terminationHandler.js#L22-L27
...do:
process.on
: this restores the 'once' wrapper. For Node v14.17.0 use process.rawListeners(eventName)
instead of process.listeners(eventName)
)process.on(signal,() => {process.exit()})
)signal
.
The Two Main Issues Addressed Here
process.exit()
or any other procedure that we don't want being executed before theterminationHandler
of the main application.process.exit()
.References
Event Loop https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout https://nodejs.dev/learn/the-nodejs-event-loop https://nodejs.dev/learn/understanding-process-nexttick https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop
Avoiding a Premature Exit
terminationHandler
, (d) restore the backuped listeners after completingterminationHandler
. => #62Workaround
process.exit()
after execution of subset C (very last). => #62Further Analysis
exit
callback do it).~ => moved to #76 .