Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Clarify omitted retry contract details, rollback boundaries, and the 40P01 deadlock code.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Documents the upcoming server-side tx.retryOn() API for retrying transient mutator failures.
Changes:
- Adds retry guidance and usage example.
- Documents backoff, limits, and transaction behavior.
- Links to the guidance from “Handling Errors.”
| File | Description |
|---|---|
contents/docs/mutators.mdx |
Adds tx.retryOn() documentation and error-handling guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| ## Retrying Mutators | ||
|
|
||
| Some failures, like losing a race with a concurrent write (`40001`, `23505`), go away if the mutator just runs again. Register a predicate with `tx.retryOn()`: if the run fails, including at `COMMIT`, Zero asks it whether to run the mutator again in a fresh transaction. |
| ) | ||
| ``` | ||
|
|
||
| Call `tx.retryOn()` at the top of the mutator, before anything that can fail. It's only available on the server, and the predicate runs after the transaction has finished, so it can't use `tx`. Returning a promise lets you back off, but keep delays short since the rest of the push waits for it. Zero runs a mutator at most five times per push, and you should only use this for mutators that are safe to run more than once. |
This branch was successfully deployed
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.

Documents
tx.retryOn(), a new server-transaction API for re-running a mutator after a transient failure. The API hasn't shipped yet, so this should merge once it's in a release.What
A new Retrying Mutators section in
mutators.mdx, after "Dropping Down to Raw SQL", plus a one-line pointer from "Handling Errors". It covers:40001,40P01,23505).COMMIT, which the mutator body can't catch.attemptnumbering; backing off by returning a promise and what that holds open; calls add up and the first yes wins; a throwing predicate counts as no; the predicate can't usetx; only database writes roll back; at most 5 runs per push.