feat(ui): make schedulePublish task queue configurable#16764
Open
ShaunMWallace wants to merge 1 commit into
Open
feat(ui): make schedulePublish task queue configurable#16764ShaunMWallace wants to merge 1 commit into
ShaunMWallace wants to merge 1 commit into
Conversation
The admin UI's schedule-publish action enqueues the built-in `schedulePublish` task without a `queue` arg, falling back to `'default'`. When a Payload deployment polls only named queues (e.g. via Vercel Cron entries with `?queue=<name>`), scheduled-publish events stall indefinitely with no editor-facing signal. Add `JobsConfig.scheduledPublishQueue?: string` and have `schedulePublishHandler` read it. Default behavior unchanged (falls to `'default'` when unset). Discovered via a Consumer Web prod report; downstream fix shipped as a default-queue cron, but a dedicated queue is cleaner.
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.
What?
Adds an optional
JobsConfig.scheduledPublishQueue?: stringconfig that controls which queue Payload's built-inschedulePublishtask is enqueued onto from the admin UI. Default behavior is unchanged — scheduled-publish jobs continue to land on the'default'queue when this option is not set.Why?
The admin UI's "Schedule Publish" action calls
payload.jobs.queue({ task: 'schedulePublish', input, waitUntil })without aqueueargument inside@payloadcms/ui/utilities/schedulePublishHandler.ts. With no consumer-side hook to thread a queue through, the job always lands on'default'.Deployments that poll Payload's job runner via Vercel Cron commonly use one cron entry per named queue (
?queue=ad-metrics,?queue=sync, etc.) and never poll'default'. In that topology, scheduled-publish events stall indefinitely: the "Upcoming Events" row in admin stays forever, the document never publishes, no editor-facing error fires.I hit this in a production deployment and traced it end-to-end. Downstream fix was a
?queue=defaultcron entry — that works, but it conflates scheduled-publish with anything else that happens to land on'default'. A dedicated queue (e.g.'schedule-publish') is cleaner:How?
Two changes, plus tests:
packages/payload/src/queues/config/types/index.ts— addscheduledPublishQueue?: stringtoJobsConfigwith a doc comment.packages/ui/src/utilities/schedulePublishHandler.ts— readpayload.config.jobs?.scheduledPublishQueueand pass it asqueuetopayload.jobs.queue(...).When the field is unset,
queueis passed asundefined, andrunJobsdefaults it to'default'(packages/payload/src/queues/operations/runJobs/index.tsline ~12:queue = 'default'). Back-compat preserved — no behavior change for any user who doesn't opt in.Tests
Two new int specs added inside the existing
test/versions/int.spec.ts > Scheduled Publish > server functionsblock:should enqueue scheduled-publish jobs on the configured queue when jobs.scheduledPublishQueue is set— sets the config, calls the handler, asserts the resultingpayload-jobsrow carriesqueue: 'schedule-publish'.should fall back to the default queue when jobs.scheduledPublishQueue is not set— deletes the config field, calls the handler, asserts the row carriesqueue: 'default'.Both pass locally on sqlite (
pnpm test:int:sqlite test/versions/int.spec.ts -t scheduledPublishQueue→ 2 passed, 98 skipped). The existingshould create using schedule-publishandshould delete using schedule-publishtests in the same block continue to pass — no regression.Build verified:
pnpm turbo build --filter 'payload^...' --filter payload --filter @payloadcms/ui(9/9 tasks green).Notes for reviewers
jobs.scheduledPublishQueuebecause it's the smallest patch surface that fully solves the immediate problem; per-collection (versions.drafts.schedulePublishQueue) could be added additively later if anyone needs to scope by collection.jobs.queues.schedulePublish) if you'd prefer different namespacing.Fixes #