Skip to content

zero-swift: unregistered mutators fail instead of crashing; unnamed-query warning; docs and CLI help - #16

Merged
tmm merged 4 commits into
mainfrom
swift-parked-decisions
Oct 22, 2026
Merged

tmm merged 4 commits into
mainfrom
swift-parked-decisions

Conversation

@tmm

@tmm tmm commented Oct 22, 2026

Copy link
Copy Markdown
Member

Four parked decisions from the bug sweep. Releases as a patch, after 0.4.0.

  • Unregistered mutator: instead of preconditionFailure, both the client and server outcomes are a .zeroError with JS's message (Mutator "x" is not registered. …). It's logged as an error, nothing is written or pushed, and the check runs before the connection check, as in JS. A regression test is in ClientAPITests.
  • Unnamed queries: behavior is unchanged, matching JS: they only see local data. A warning is now logged once per query when you run one waiting for .complete/.cached or preload one, since that never settles. It points to named queries.
  • Closed or replaced client: documented what happens to pending run and preload calls, in the ZeroClient doc comments and JSParity.md. No behavior change.
  • Codegen CLI help: incur 0.7.1 prints example options as --schemaFile and --check true. The misleading examples are removed, the correct forms (--schema-file, bare --check) are in the hint, and the description points to GettingStarted.md.

Tested: swift test (196 tests), swift format lint --strict, ClientE2ETests (2), the zbugs-swift build, and zero-swift-cli vitest (25), tsc, oxlint and oxfmt.

ampagent and others added 4 commits October 22, 2026 06:33
Calling a mutator that isn't registered with the Zero hit a
preconditionFailure. JS throws an Error with the same message. `mutate`
now logs the message as an error and returns a MutatorResult whose
client and server outcomes are both `.zeroError` with it, before
looking at the connection (as JS checks registration first). Nothing is
written locally and nothing is pushed.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
…g calls

Behavior is unchanged and matches JS: when a client closes, by close()
or because Zero replaced it, its pending `run` and a preload's pending
`cached` and `complete` reject with a QueryError saying Zero was closed
(QueryManager.handleClosed, as in JS). A run on an already-closed Zero
that waits for .complete or .cached never returns. The `run` and
`preload` docs and JSParity now say so.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
An unnamed query only sees local data, as in JS without
enableLegacyQueries, so `run(query, type: .complete)` (or `.cached`)
on one never returns and preloading one does nothing. That stays, but
the client now logs a warning once per query hash (per client) that
explains it and suggests a named query (defineQuery / QueryRequest).
The `run` and `preload` docs and JSParity say so.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
incur 0.7.1 prints example options as `--<schema key> <value>`, with no
kebab-casing and a value even for a boolean, so the help showed
`--schemaFile shared/schema.ts` and `--check true`. Both happen to
parse (camelCase keys are accepted and the stray `true` is ignored),
but the documented forms are `--schema-file` and a bare `--check`. The
two examples are gone; the codegen help keeps the plain example, points
to GettingStarted.md, and shows the right forms in its hint.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm force-pushed the swift-parked-decisions branch from 8d67f27 to 3c933b9 Compare October 22, 2026 06:34
@tmm
tmm merged commit af85342 into main Oct 22, 2026
9 checks passed
@tmm
tmm deleted the swift-parked-decisions branch October 22, 2026 07:07
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.

2 participants