DocsUsing RIMVersion skew between client and server

Version skew between client and server

A desktop client lives longer than the server it talks to: users update the app when they choose, and an operator updates the server when they choose. A client release that sends a field or a mutation an older server does not have gets the whole operation refused, not just that field.

npm run skew:check shows which operations those are.

npm run skew:check -- <git ref>   # e.g. v0.3.0, origin/release, HEAD~30
npm run skew:check                # the most recent rim-ui v* tag

It takes schema.graphql as committed at the ref (the SDL exported from the server that the client was built against then), collects every gql document under src/ with its fragments resolved the way the client sends it, validates each against that schema with graphql's validate, and prints the operations that fail, grouped by file. It exits 1 when any would be refused, 0 when none would, and 2 when it cannot run (no such ref, no schema.graphql there). With no argument and no v* tag yet, it says how to pass a ref and exits 0.

Test files, test helpers and fixtures are not checked; neither is the health check's introspection query, which every server answers.

When to run it #

  • Before tagging a client release, against the oldest server release the new client should still work with, at the least the one production runs. rim-ui's tags no longer follow the server's version, so pass a ref whose schema.graphql is that server's SDL: the rim-ui commit that exported it, or a commit with the SDL of that server version exported again. Every operation it lists is a feature that breaks for users on that server: either gate it behind a capability the server reports, or state that the release needs a newer server.
  • When a change adds a field to an existing query. A new field in a query that already worked turns the whole query into a refusal on an older server, which is easy to miss in review. Running against the last release tag shows it.
  • After npm run codegen picks up a new schema, to see what the client would now ask an older server for.

A failure against the current HEAD means the client sends something the committed schema does not have at all: a bug today, not skew.

Gating a new field #

A field an older server lacks is asked for only when serverInfo.capabilities names it. serverHasCapability (src/features/updater/api/serverCapabilities.ts) reads the cached server info; the read keeps a second document with the field (MessagesWithEdits beside Messages), built from the same constants, and picks one per request. scripts/skew-check.test.mjs checks that only the gated documents fail against a schema without the field. npm run skew:check lists the gated documents; each listed one must be gated or have a fallback.

A control that runs a new mutation is shown only when the capability names it: Leave workspace (workspace_leave), Rename workspace (workspace_rename), and Delete messages, with the ban dialog's message deletion (delete_member_messages). A workspace on another server is gated by the relay's capabilities; its host, if older, refuses the document, and the app says the workspace's server does not support it yet.

A read every workspace depends on goes by the capabilities of the workspace's own host instead: spaceHasCapability asks that host through the same route as the workspace's other requests and keeps the answer for a few minutes. The unread counts ask for unreadAfter this way (read_marker), so a workspace on an older host keeps its badges under a newer relay. What those counts brought then gates Mark unread from here and Mark as unread, also by the workspace's host.

Rendered from rim-ui/docs/version-skew.md at bcefe82