Subscribes to fatal execution errors with queued async processing.
Listens to critical errors that terminate execution (Live.background, Backtest.background, Walker.background).
Unlike listenError (recoverable errors), these errors stop the current process.
Events are processed sequentially in order received, even if callback is async.
Uses queued wrapper to prevent concurrent execution of the callback.
Parameters
fn: (error:Error)=>void
Callback function to handle fatal error events
Returns ()=>void
Unsubscribe function to stop listening
Example
import { listenExit } from"./function/event";
constunsubscribe = listenExit((error) => { console.error("Fatal error (execution terminated):", error.message); // Log to monitoring, send alerts, restart process, etc. });
Subscribes to fatal execution errors with queued async processing.
Listens to critical errors that terminate execution (Live.background, Backtest.background, Walker.background). Unlike listenError (recoverable errors), these errors stop the current process. Events are processed sequentially in order received, even if callback is async. Uses queued wrapper to prevent concurrent execution of the callback.