-
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.
timers: reschedule interval even if it threw
To match browser behaviour, intervals should continue being scheduled even if the user callback threw during execution. PR-URL: #20002 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
a3bd06a
commit 198eb9c
Showing
3 changed files
with
37 additions
and
12 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
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,17 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
// To match browser behaviour, interval should continue | ||
// being rescheduled even if it throws. | ||
|
||
let count = 2; | ||
const interval = setInterval(() => { throw new Error('IntervalError'); }, 1); | ||
|
||
process.on('uncaughtException', common.mustCall((err) => { | ||
assert.strictEqual(err.message, 'IntervalError'); | ||
if (--count === 0) { | ||
clearInterval(interval); | ||
} | ||
}, 2)); |