Skip to content

Conversation

@noahc3
Copy link
Contributor

@noahc3 noahc3 commented Nov 21, 2025

Add functionality to automatically register a queue worker for branch preview deployments. This is necessary to process jobs and notifications if your application uses an asynchronous queue like Redis.

  • add-worker: bool [optional, default: false]
  • worker-connection: string [required if add-worker is true]
  • worker-queue: string | undefined [optional, default: undefined which means use the default queue]

new functions in forge.ts (these wrap the relevant Workers API endpoints):

  • static async createWorker(server: number, site: number, connection: string, queue?: string | undefined)
  • static async listWorkers(server: number, site: number)
  • static async deleteWorkers(server: number, site: number, worker: number)

Note: similar to scheduled jobs, Forge automatically cleans up workers when the site is deleted, so while listWorkers and deleteWorkers functions are provided, they are never actually called (due to the potential issue noted with deleting scheduled jobs, though I never tested it with workers)

Note: Users are responsible for including a line to restart the queue worker on push in their deploy script.

README is updated to document the new parameters.

Manual testing performed:

  • Confirmed workers are successfully created and appear in Forge console
  • Confirmed the hardcoded parameters passed to the create endpoint produce a resulting worker configuration identical to creating one manually in the Forge console with default settings
  • Confirmed the workers work (jobs on the queue are processed correctly)
  • Confirmed deleting the site automatically deletes the worker without needing manual cleanup in the action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant