mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
f5ed3386fd
Emit process warning once per process when delay is a negative number or not a number, this will prevent unexpected behaviour caused by invalid `delay` also keep the consistency of the behaviour and warning message for `TIMEOUT_MAX` number As the negative number is invalid delay will be set to 1. PR-URL: https://github.com/nodejs/node/pull/46678 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
32 lines
538 B
JavaScript
32 lines
538 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
function timerNotCanceled() {
|
|
assert.fail('Timer should be canceled');
|
|
}
|
|
|
|
process.on(
|
|
'warning',
|
|
common.mustNotCall(() => {
|
|
assert.fail('Timer should be canceled');
|
|
})
|
|
);
|
|
|
|
{
|
|
const timeout = setTimeout(timerNotCanceled, 0);
|
|
clearTimeout(timeout);
|
|
}
|
|
|
|
{
|
|
const interval = setInterval(timerNotCanceled, 0);
|
|
clearInterval(interval);
|
|
}
|
|
|
|
{
|
|
const timeout = setTimeout(timerNotCanceled, 0);
|
|
timeout.refresh();
|
|
clearTimeout(timeout);
|
|
}
|