DocsMessages & jobs
On this page

Retry selected job work

Retry failed work and continue until a task is complete.

Before you begin: Pause a job at a rate limit.

Retry only the work you choose

job.emit(data) inside a retryable block is delivered after that block succeeds and its post writes commit. Failed attempts discard their buffered feedback. Keep feedback within each block under 64 KiB (each message can be up to 4 KiB); emit ongoing progress outside the block when it should appear immediately.

A retryable(key) block is the unit of retry. Its key is a readable label for feedback, such as "send-email". You can reuse a label across items, blocks, and helper calls: each execution is tracked independently. If a block fails, its error is recorded and execution continues with the next independent block or item.

When one step depends on another in the same loop item or helper invocation, name the earlier block with after:

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

If registration fails, sending is saved as blocked with zero attempts and emits action.blocked instead of an action failure. Retrying waits for registration to succeed before attempting sending. Independent blocks still run, and a blocked step does not add another failed item to the progress counter. Use distinct labels for dependent steps; after refers to the latest earlier occurrence of that label in this iteration or helper invocation. A missing earlier label is an error.

Each block restores its own captured values on retry. Values returned by a retried predecessor are not injected into another block, so recover any needed external session or result explicitly, as the login above does. Successful blocks are not repeated.

Failure entries include a unique id and your label as key. Use id when identifying a particular failed action in your UI. A label is not an idempotency key: using the same label twice does not suppress either execution. For an external service that supports idempotency, provide its idempotency key in the request itself.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

One job ID retries its failed registered blocks, using each group’s concurrency limit. Blocks that already succeeded are not rerun. If a retry is already running, another retry request returns its current status. A completed job with no eligible failed blocks is unchanged.

Within a retryable block, $retry.attempt starts at 1 and increases on retry; $retry.previousError contains the preceding failure. Local values and helper arguments captured before the first attempt are restored. In the example above, the generated username stays the same on retry.

You can have several independent retryable blocks in one item, or put a block inside an FRL fn. A block's entire body is rerun, so choose its boundaries carefully: if account creation succeeds and logging fails in the same block, retrying that block repeats account creation too. Put independently retryable work in separate blocks with the data each needs available before its block begins.

Use job.fail({message: "...", code: "..."}) to record a failure detected from an API response. Ordinary FRL errors and failed must checks are also recorded. Post writes staged by a failing block are discarded; successful external calls cannot be undone. Nest atomic inside a retryable block when its database changes must commit together. Retryable blocks cannot nest inside each other.

Interrupted operations are excluded by default. After your endpoint performs the appropriate checks, job.retry(id, {includeInterrupted: true}) explicitly includes them. An interrupted item can remain marked interrupted even after its registered block succeeds, because the rest of that item's body may not have run. Use your own reconciliation endpoint for those outcomes.

FRL does not choose business retry policies. Your theme decides how to reconcile uncertain responses, whether to reuse an external idempotency key, and when a retry is safe. Work outside a retryable block is not automatically replayed.

job.get(id) reads a snapshot inside FRL. job.cancel(id) requests cancellation from an endpoint. The creator-only access check applies to all job operations; endpoints can impose additional business permissions.

Job watchers display current progress immediately. On connection or when feedback is missed, they catch up with at most the latest 100 events per request, without downloading the entire backlog. Older feedback is available explicitly through Frontbacked.jobs.events(id, after). Catch-up requests are driven by new progress updates, not a polling timer. Use the job snapshot for authoritative totals; do not calculate totals by counting feedback callbacks.

Repeat until work is finished

Use while directly in a job when the number of pages is unknown:

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

The job continues independently of the browser and can resume between statements. Make each page safe to repeat if a request is interrupted. Ensure the condition eventually becomes false; do not use a loop to poll for future work. Inside an endpoint or helper function, while is limited to 100 iterations.