node/test/parallel/test-timers-max-duration-warning.js
Jeremiah Senkpiel 7c80f18c41 timers: deprecate active() and _unrefActive()
Another nail in the coffin here, farewell ye ol C-style apis.

These apis caused numerous other issues that required far too many
safeguards. This gets us one step closer to not having to worry about
those issues anymore.

Refs: https://github.com/nodejs/node/pull/18066
Refs: https://github.com/nodejs/node/pull/20298

PR-URL: https://github.com/nodejs/node/pull/26760

Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-22 19:47:32 -07:00

43 lines
971 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() {
assert.fail('Timer should be canceled');
}
process.on('warning', common.mustCall((warning) => {
if (warning.name === 'DeprecationWarning') return;
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);
}, 6));
{
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);
}