once names the logical mutation, and seen asks a
later read to include what it committed.
One identity: once
client.mutate(fn, args, { once }) names one logical mutation. The host
keeps the result of each once:
- the same
oncewith the same arguments answers the original result, and runs nothing again; - the same
oncewith other arguments refusesInvalid.
once, the client mints one for that call. Give your own
when the identity belongs to something the user did, such as a form
submission you may send again after a reload.
For a signed-out caller, use the same JavaScript client for retries while
its registration can recover the request. For signed-in callers, the
installation keeps the business decision across transport registrations.
After a reload, retry as the same signed-in identity in the original world
and calling scope.
apps/main/src/client.ts
apps/main/src/submit.ts
When the answer is Unknown
Unknown means the mutation may have committed. The refusal carries its
original once, including when the client minted it. Send that key with the
same arguments. The server returns the original result if it committed or
executes the mutation for the first time.
apps/main/src/retry.ts
useMutation, pass the refusal’s once to the hook’s callable as
add(args, { once }) to retry. See React.
Failed is different: it definitely did not happen. Retrying a Failed
call runs the mutation for the first time.
Retain a submission before sending
For a signed-in client with a pinned calling contract, useprepareMutation when you need recovery across a reload or process exit.
It registers the request and returns private recovery material before the
mutation is sent. Save value.retained in your application’s private
storage and keep value.reference for support. Prepared mutations carry
inline arguments. Use the regular mutation path for staged File uploads.
apps/main/src/recover-draft.ts
{ mode: "inspect" } to read the original decision only. A resume
can send the prepared request in its original slot when that slot is
unresolved and still admits the mutation. Clear saved recovery material
after a usable decision or recovery expiry. If the result stays
unavailable, look up the business record through the app.
For a retained bijection call, --inspect <path> reads its decision
and --recover <path> can resume the same request. The call prints its
release-independent submission reference before it sends.
Read your own writes: version and seen
A committed mutation’s result carries its commit version. Pass it as
seen to a later call, watch or hook, and the answer comes from state at
least that new.
apps/main/src/add-and-list.ts
seen is accepted by client.query, client.watch, client.trial,
client.mutate, useWatch, usePages and useMutation. A read without it
may answer from a slightly older state than a mutation the same client just
committed over another connection.
Wait for application work
Some mutations start work that continues after the transaction commits. When the author declares acompletion query, the mutation’s result
value is a portable receipt.
apps/main/src/refresh-counts.ts
wait watches the declared query on the installation and world recorded
in the receipt and reads at or after the launch commit. It finishes when
the query reports completed or refused. A later reader uses their own
authorization and the same launch floor. An abort signal ends the wait, so
another process can resume it later. The same receipt works with Go’s
Wait, wait in the Java, Kotlin, Python, Swift, and TypeScript SDKs,
and bijection wait <receipt>.
If the mutation reply is Unknown, retry it through the same client with
the original arguments and once to recover its registered result. Once
you have the portable receipt, resuming just reads the application’s progress.
Exactly once across the boundary
once covers one client mutation. Work a mutation hands to the outside
world is a task submitted with ctx.submit(target, args, { once }) inside
the transaction: it commits atomically with the mutation’s writes, so a
retried mutation that answers its original result submits nothing new. See
Effects.