1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const timers = require('timers'); 6 7const OVERFLOW = Math.pow(2, 31); // TIMEOUT_MAX is 2^31-1 8 9function timerNotCanceled() { 10 assert.fail('Timer should be canceled'); 11} 12 13process.on('warning', common.mustCall((warning) => { 14 if (warning.name === 'DeprecationWarning') return; 15 16 const lines = warning.message.split('\n'); 17 18 assert.strictEqual(warning.name, 'TimeoutOverflowWarning'); 19 assert.strictEqual(lines[0], `${OVERFLOW} does not fit into a 32-bit signed` + 20 ' integer.'); 21 assert.strictEqual(lines.length, 2); 22}, 6)); 23 24 25{ 26 const timeout = setTimeout(timerNotCanceled, OVERFLOW); 27 clearTimeout(timeout); 28} 29 30{ 31 const interval = setInterval(timerNotCanceled, OVERFLOW); 32 clearInterval(interval); 33} 34 35{ 36 const timer = { 37 _onTimeout: timerNotCanceled 38 }; 39 timers.enroll(timer, OVERFLOW); 40 timers.active(timer); 41 timers.unenroll(timer); 42} 43