Skip to main content
server.Scheduler An interface to schedule Bijection functions to run in the future. Available as ctx.scheduler in mutations and actions. Execution guarantees:
  • Scheduled mutations are guaranteed to execute exactly once. They are automatically retried on transient errors.
  • Scheduled actions execute at most once. They are not retried and may fail due to transient errors.
Consider using an internalMutation or internalAction to ensure that scheduled functions cannot be called directly from a client. Example
See https://docs.bijection.com/scheduling/scheduled-functions

Methods

runAfter

▸ runAfter<FuncRef>(delayMs, functionReference, ...args): Promise<GenericId<"_scheduled_functions">> Schedule a function to execute after a delay. Example

Type parameters

Parameters

Returns

Promise<GenericId<"_scheduled_functions">> The ID of the scheduled function in the _scheduled_functions system table. Use this to cancel it later if needed.

runAt

▸ runAt<FuncRef>(timestamp, functionReference, ...args): Promise<GenericId<"_scheduled_functions">> Schedule a function to execute at a specific time. Example

Type parameters

Parameters

Returns

Promise<GenericId<"_scheduled_functions">> The ID of the scheduled function in the _scheduled_functions system table.

cancel

▸ cancel(id): Promise<void> Cancel a previously scheduled function. For scheduled actions: if the action has not started, it will not run. If it is already in progress, it will continue running but any new functions it tries to schedule will be canceled. If it had already completed, canceling will throw an error. For scheduled mutations: the mutation will either show up as “pending”, “completed”, or “failed”, but never “inProgress”. Canceling a mutation will atomically cancel it entirely or fail to cancel if it has committed. It is a transaction that will either run to completion and commit or fully roll back. Example

Parameters

Returns

Promise<void>