fix(service-job): migrate early registrations across the placeholder→DbJobAdapter upgrade — cron jobs finally run - #4172
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 6 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…DbJobAdapter upgrade Business plugins start() before kernel:ready, so their schedules all land on the placeholder IntervalJobAdapter — which silently ignores cron schedules — and the upgrade swapped the service without migrating anything. Default config result: cron jobs never ran at all, while interval timers kept running on the orphaned placeholder, invisible to sys_job. The upgrade now snapshots every early registration, stops the placeholder, and re-schedules them on the DbJobAdapter. The IntervalJobAdapter warns per cron registration it cannot execute, and the no-engine path summarizes the stranded cron jobs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #4174
Summary
Plugin-registered cron jobs never fired in the default (
adapter: 'auto'/'db') configuration. Three stacked causes, found via real-app dogfooding (A/B measured: an interval 15s job ran 23 times while a cron*/1 * * * *job ran 0 times):JobServicePlugin.initregisters a placeholderIntervalJobAdaptersynchronously so callers cangetService('job')during init — but that placeholder silently ignorescronschedules (no timer, no error).DbJobAdapterhappens inkernel:ready, which runs after every business plugin'sstart()— so all their registrations land on the placeholder.replaceServicewithout migrating the already-registered jobs: cron entries were lost for good, and the placeholder's interval timers kept running on the orphaned adapter — which is exactly why interval jobs looked healthy while cron jobs did nothing, and why none of them showed up insys_job.Fix
kernel:readyupgrade now snapshots every registration made against the placeholder (getRegistrations()), stops the placeholder first (a brief gap beats a double-fire), then re-schedules everything on theDbJobAdapter— whose cron routing makes the cron entries actually run and persists them tosys_job.IntervalJobAdapterwarns per cron registration it cannot execute (it has no cron engine), and the no-engine path summarizes stranded cron jobs in one line instead of staying silent.replaceServicefailure now returns early instead of migrating onto a service nobody resolves.Tests
job-service-plugin.test.ts: early cron + interval registrations both follow the upgrade (service swapped,listJobscomplete,sys_jobrows present, placeholder emptied, migrated handler still fires viatrigger); the no-engine path warns loudly about stranded cron jobs.pnpm vitest runinpackages/services/service-job: 5 files, 39 tests, all green;pnpm buildclean.🤖 Generated with Claude Code