Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
I have a job that is scheduled to run "every 1 minute" and takes about 5 seconds to complete. Every so often Bree will think the job is already running when it isn't, then will then happily start it running anyway. Here's an example from my logs:
2024-01-26T02:10:12.437Z [jobs] Worker deleted: getVatsimData
2024-01-26T02:10:12.438Z [jobs] Current jobs: getVatsimEndpoints, importAirports, getVatsimData, getVatsimTransceivers
2024-01-26T02:10:12.439Z [jobs] Current workers:
2024-01-26T02:10:59.996Z [jobs] Worker created: getVatsimData
2024-01-26T02:10:59.997Z [jobs] Current jobs: getVatsimEndpoints, importAirports, getVatsimData, getVatsimTransceivers
2024-01-26T02:10:59.997Z [jobs] Current workers: getVatsimData
2024-01-26T02:11:00.001Z [jobs] Error: Job "getVatsimData" is already running
2024-01-26T02:11:00.063Z [jobs] Worker for job "getVatsimData" online
I'm using the worker created and worker deleted events to write out the current jobs and current workers when jobs are created and deleted. In the logs above getVatsimData finished running at 2:10:12 and there were no active workers when it exited. The next run of the job started at 2:10:59 and resulted in the "already running" error, but then started anyway just 62ms later.
Describe the bug
Node.js version: 20.11.x
OS version: Alpine 3.18
Description:
I have a job that is scheduled to run "every 1 minute" and takes about 5 seconds to complete. Every so often Bree will think the job is already running when it isn't, then will then happily start it running anyway. Here's an example from my logs:
I'm using the
worker created
andworker deleted
events to write out the current jobs and current workers when jobs are created and deleted. In the logs abovegetVatsimData
finished running at 2:10:12 and there were no active workers when it exited. The next run of the job started at 2:10:59 and resulted in the "already running" error, but then started anyway just 62ms later.Expected behavior
No warning.
Code to reproduce
No standalone code, but my bree code is in a single file in my repo.
Checklist