-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timer,domain: maintain order of timer callbacks
PR-URL: #10522 Fixes: #1271 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
- Loading branch information
1 parent
92f6919
commit d71ebb9
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that the timer callbacks are called in the order in which | ||
// they were created in the event of an unhandled exception in the domain. | ||
|
||
const domain = require('domain').create(); | ||
const assert = require('assert'); | ||
|
||
let first = false; | ||
|
||
domain.run(function() { | ||
setTimeout(() => { throw new Error('FAIL'); }, 1); | ||
setTimeout(() => { first = true; }, 1); | ||
setTimeout(() => { assert.strictEqual(first, true); }, 2); | ||
|
||
// Ensure that 2 ms have really passed | ||
let i = 1e6; | ||
while (i--); | ||
}); | ||
|
||
domain.once('error', common.mustCall((err) => { | ||
assert(err); | ||
assert.strictEqual(err.message, 'FAIL'); | ||
})); |