-
Notifications
You must be signed in to change notification settings - Fork 633
Description
Description
Hi there, upgraded to Node.js 24 and occasionally getting this warning:
(node:32202) TimeoutNegativeWarning: -2 is a negative number.
Timeout duration was set to 1.
at new Timeout (node:internal/timers:195:17)
at setTimeout (node:timers:120:19)
at setCronTimeout (/Users/xxx/Projects/xxx/node_modules/cron/dist/job.js:155:29)
at Timeout.callbackWrapper [as _onTimeout] (/Users/xxx/Projects/xxx/node_modules/cron/dist/job.js:178:17)
at listOnTimeout (node:internal/timers:608:17)
at process.processTimers (node:internal/timers:543:7)
It's not affecting the program, just a little annoying.
Postgres.js (A PostgreSQL/Node.js driver library) has reported a similar issue: porsager/postgres#1061
Expected Behavior
Should not randomly throw that warning.
Actual Behavior
Randomly throwing out the above warning message.
Possible Fix
No response
Steps to Reproduce
CronJob.from({
cronTime: '0 */1 * * * *',
onTick: async () => {
await FUNC_1();
},
start: true
});
CronJob.from({
cronTime: '0 */10 * * * *',
onTick: async () => {
await FUNC_2();
await FUNC_3();
},
start: true
});
CronJob.from({
cronTime: '0 */30 * * * *',
onTick: async () => {
await FUNC_4();
}
});Above are the actual code of how I'm using cron. All FUNC has async/external resource/IO blocking behaviour, like Database query (Postgres), Fetch, File IO.
Context
Fortunately it's not affecting the program logic, just throwing a warning message. It's possible that the warning prohibits one cron job from running, but as you can tell from the code above, I just need to wait for another several minutes for the cron job to re-run. None of the tasks I run is time-sensitive, so it's acceptable.
Your Environment
cronversion: 4.3.1- NodeJS version: v24.3.0
- Operating System and version: MacOS Sequoia 15.5
- TypeScript version (if applicable): JavaScript
- Link to your project (if applicable): It's a company private project sorry