mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 06:19:07 +00:00

To match browser behaviour, intervals should continue being scheduled even if the user callback threw during execution. PR-URL: https://github.com/nodejs/node/pull/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>
18 lines
453 B
JavaScript
18 lines
453 B
JavaScript
'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));
|