node/lib/internal/modules/esm/handle_process_exit.js
Geoffrey Booth 7517c9f95b
module, esm: jsdoc for modules files
PR-URL: https://github.com/nodejs/node/pull/49523
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
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,
};