Files
node/lib/internal/modules/esm/handle_process_exit.js
T
2023-09-19 02:48:24 +00:00

17 lines
432 B
JavaScript

'use strict';
const { exitCodes: { kUnfinishedTopLevelAwait } } = internalBinding('errors');
/**
* Handle a Promise from running code that potentially does Top-Level Await.
* In that case, it makes sense to set the exit code to a specific non-zero value
* if the main code never finishes running.
*/
function handleProcessExit() {
process.exitCode ??= kUnfinishedTopLevelAwait;
}
module.exports = {
handleProcessExit,
};