MCPcopy Index your code
hub / github.com/nodejs/node / exitHandler

Function exitHandler

lib/internal/test_runner/harness.js:262–293  ·  view source on GitHub ↗
(kill)

Source from the content-addressed store, hash-verified

260 setupFailureStateFile(root, globalOptions);
261
262 const exitHandler = async (kill) => {
263 if (root.subtests.length === 0 && (root.hooks.before.length > 0 || root.hooks.after.length > 0)) {
264 // Run global before/after hooks in case there are no tests
265 await root.run();
266 }
267
268 if (kill !== true && root.subtestsPromise !== null) {
269 // Wait for all subtests to finish, but keep the process alive in case
270 // there are no ref'ed handles left.
271 const keepAlive = setInterval(() => {}, TIMEOUT_MAX);
272 await root.subtestsPromise.promise;
273 clearInterval(keepAlive);
274 }
275
276 root.postRun(new ERR_TEST_FAILURE(
277 'Promise resolution is still pending but the event loop has already resolved',
278 kCancelledByParent));
279
280 if (root.harness.globalTeardownFunction) {
281 await root.harness.globalTeardownFunction();
282 root.harness.globalTeardownFunction = null;
283 }
284
285 hook.disable();
286 process.removeListener('uncaughtException', exceptionHandler);
287 process.removeListener('unhandledRejection', rejectionHandler);
288 process.removeListener('beforeExit', exitHandler);
289 if (globalOptions.isTestRunner) {
290 process.removeListener('SIGINT', terminationHandler);
291 process.removeListener('SIGTERM', terminationHandler);
292 }
293 };
294
295 const findRunningTests = (test, running = []) => {
296 if (test.startTime !== null && !test.finished) {

Callers 2

terminationHandlerFunction · 0.85
exit-handler.jsFile · 0.85

Calls 6

clearIntervalFunction · 0.85
setIntervalFunction · 0.50
runMethod · 0.45
postRunMethod · 0.45
disableMethod · 0.45
removeListenerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…