aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2017-12-23 10:39:52 -0500
committerAnatoli Papirovski <apapirovski@mac.com>2017-12-28 11:38:13 -0500
commit41f8c8d121e2854aba53e378357323dbdd49c936 (patch)
treee30d820541aeae1d773bd1ab17a9e8ac18ad54b0 /test
parentfd724c5c638d97545e055cdae80a087f077af28a (diff)
downloadandroid-node-v8-41f8c8d121e2854aba53e378357323dbdd49c936.tar.gz
android-node-v8-41f8c8d121e2854aba53e378357323dbdd49c936.tar.bz2
android-node-v8-41f8c8d121e2854aba53e378357323dbdd49c936.zip
process: do not directly schedule _tickCallback in _fatalException
When a process encounters a _fatalException that is caught, it should schedule execution of nextTicks but not in an arbitrary place of the next Immediates queue. Instead, add a no-op function to the queue that will ensure processImmediate runs, which will then ensure that nextTicks are processed at the end. PR-URL: https://github.com/nodejs/node/pull/17841 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-process-fatal-exception-tick.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-process-fatal-exception-tick.js b/test/parallel/test-process-fatal-exception-tick.js
new file mode 100644
index 0000000000..19678d2922
--- /dev/null
+++ b/test/parallel/test-process-fatal-exception-tick.js
@@ -0,0 +1,24 @@
+'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));
+});
+const now = Date.now();
+setTimeout(() => setImmediate(() => stage++), 1);
+while (now + 10 >= Date.now());
+throw new Error('caughtException');