0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-process-fatal-exception-tick.js
Rich Trott a025723e01 test: fix flaky test-process-fatal-execption-tick
Use common.busyLoop() which happens to make the test robust.

PR-URL: https://github.com/nodejs/node/pull/18461
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-01-30 20:27:57 -08:00

24 lines
578 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
// If a process encounters an uncaughtException, it should schedule
// processing of nextTicks on the next Immediates cycle but not
// before all Immediates are handled
let stage = 0;
process.once('uncaughtException', common.expectsError({
type: Error,
message: 'caughtException'
}));
setImmediate(() => {
stage++;
process.nextTick(() => assert.strictEqual(stage, 2));
});
setTimeout(() => setImmediate(() => stage++), 1);
common.busyLoop(10);
throw new Error('caughtException');