fix: providers.refresh queue is created on scheduler startup#302
Merged
fix: providers.refresh queue is created on scheduler startup#302
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a race condition where workers could start polling for jobs before the scheduler created the providers.refresh queue, causing intermittent startup errors. The fix ensures all worker-consumed queues are created explicitly during worker startup, making queue creation independent of scheduler timing.
Changes:
- Refactored queue creation into a dedicated
ensureWorkerQueues()helper method - Added explicit creation for all four worker-consumed queues:
sp.work,metrics.run,metrics.cleanup, andproviders.refresh - Updated tests to verify all worker queues are created and registered properly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/backend/src/jobs/jobs.service.ts | Extracted queue creation logic into ensureWorkerQueues() method and added creation for all worker-consumed queues |
| apps/backend/src/jobs/jobs.service.spec.ts | Added test for new ensureWorkerQueues() method and updated existing test to use queue constants instead of hardcoded strings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
silent-cipher
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes intermittent worker startup errors:
Queue providers.refresh does not exist (Queue: providers.refresh, Worker: ...)Root Cause
JobsServiceregistered a worker forproviders.refresh, but startup only explicitly createdsp.work.In our deployed topology (
DEALBOT_RUN_MODE=worker,DEALBOT_PGBOSS_SCHEDULER_ENABLED=false), workers can start polling before the scheduler ever createsproviders.refresh, causing repeated pg-boss errors.Fix
sp.work(singleton policy)metrics.runmetrics.cleanupproviders.refreshensureWorkerQueues(...)helper invoked fromstartBoss().Tests
providers.refreshworker registration.pnpm -C apps/backend test -- src/jobs/jobs.service.spec.tsNotes
createQueueis idempotent and avoids scheduler/worker startup races.