# Problem code `'sync-failed'`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts`, `tables/problems.json` and `services/onsite-scripter/scripts/contract-docs-what-to-do.json` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

A member of [`ProblemCode`](../api/ProblemCode.md) · stable · since 2.0.0

An internal failure while the runtime applied a state write, recorded or look-only ([`setSceneModel`](../api/Writer.setSceneModel.md), `undo`, [`Collection.set`](../api/Collection.set.md), [`stage.set`](../api/Stage.set.md), `attach`, a rule), through `session` or a `tx`, before its commit point: it, or the transaction holding it, rolled back with reason 'internal-error'; or while it applied a commit the runtime makes itself (a `commit: 'runtime'` drag's, a 'restore'), which rolls back, carries that commit's `op` (a drag's also its unit's `node`, the `op` its 'drag:end' carried) and releases a held drop pose; or when a member's on-demand code failed to load, for a write or a synchronous call that waited for it (spec section 6.3).

## What to do

An internal failure: the state write (or its transaction) rolled back with reason 'internal-error' and the scene shows the state before it, or a member's on-demand code failed to load. Make the same call once more, as the [`setSceneModel`](../api/Writer.setSceneModel.md) example does, and report it when that fails too.

```ts
const r = await session.setSceneModel(model);
if (r.outcome === 'rolled-back' && r.reason === 'internal-error') await session.setSceneModel(model);
```

## Where the declaration names it

- [`Collection.load`](../api/Collection.load.md): If its commit through `session` fails inside the runtime, the item is dropped the same way and 'sync-failed' is recorded with its `op` and `path` (spec section 6.4).
- [`DragOptions.commit`](../api/DragOptions.commit.md): If that commit fails inside the runtime, it rolls back, records 'sync-failed' with its `op` and releases the held pose, so the unit shows its scene-model pose from the next frame (spec section 6.4).
- [`Events.drag:end`](../api/Events.drag_end.md): `cause` is that commit's when it applied before this dispatch, else null: one still queued behind an earlier write reports itself by its state events and the feed entry whose `cause.op` is `op` (`cause.kind` 'input'), or by 'sync-failed' with that `op` and the unit's `node` (spec section 6.4); an equal drop records neither (O15).
- [`InfoReport.problems`](../api/InfoReport.problems.md): This session's recent Problems, oldest first: the last 50 of any code, plus the last 20 'asset-failed', 'sync-failed' and 'render-lost' entries even when older, so budget codes never push those out.
- [`Problem.node`](../api/Problem.node.md): For the 'sync-failed' of a `commit: 'runtime'` drag's commit, the dragged unit's node.
- [`Reason`](../api/Reason.md): - 'internal-error': applying a state write, recorded or look-only, through `session` or a `tx`, failed inside the runtime before its commit point; that write, or the transaction holding it, rolled back and lists 'sync-failed' in `problems` (spec section 6.4).
- [`Writer`](../api/Writer.md): Every state write through a writer or its handles that fails inside the runtime before its commit point rolls back and records 'sync-failed' once.
- [`testing.FakeSession.script`](../api/testing.FakeSession.script.md): 'runtime.input' forces the next drag release's runtime commit and 'runtime.restore' the next 'restore' commit; their only row is 'sync-failed', their default `problem`.

The set is open: handle a code you don't know (`'other'`).

## Recorded by

- the table row `failure-matrix/cases/internal-failure` (`tables/failure-matrix.json`)
- the table row `failure-matrix/cases/internal-failure-load-commit` (`tables/failure-matrix.json`)
- the table row `failure-matrix/errorCases/imperative-load-fails` (`tables/failure-matrix.json`)
- the table row `failure-matrix/errorCases/code-unavailable` (`tables/failure-matrix.json`)
