mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
ce3586da31
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: https://github.com/ayojs/ayo/pull/71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> PR-URL: https://github.com/nodejs/node/pull/15627 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
41 lines
917 B
JavaScript
41 lines
917 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const timers = require('timers');
|
|
|
|
const OVERFLOW = Math.pow(2, 31); // TIMEOUT_MAX is 2^31-1
|
|
|
|
function timerNotCanceled() {
|
|
common.fail('Timer should be canceled');
|
|
}
|
|
|
|
process.on('warning', common.mustCall((warning) => {
|
|
const lines = warning.message.split('\n');
|
|
|
|
assert.strictEqual(warning.name, 'TimeoutOverflowWarning');
|
|
assert.strictEqual(lines[0], `${OVERFLOW} does not fit into a 32-bit signed` +
|
|
' integer.');
|
|
assert.strictEqual(lines.length, 2);
|
|
}, 3));
|
|
|
|
|
|
{
|
|
const timeout = setTimeout(timerNotCanceled, OVERFLOW);
|
|
clearTimeout(timeout);
|
|
}
|
|
|
|
{
|
|
const interval = setInterval(timerNotCanceled, OVERFLOW);
|
|
clearInterval(interval);
|
|
}
|
|
|
|
{
|
|
const timer = {
|
|
_onTimeout: timerNotCanceled
|
|
};
|
|
timers.enroll(timer, OVERFLOW);
|
|
timers.active(timer);
|
|
timers.unenroll(timer);
|
|
}
|