# Problem code `'handle-disposed'`

> 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

A disposed handle or removed part was used; nothing happened.

## What to do

Stop writing through the disposed collection or removed part; get a live handle again ([`session.collection(name)`](../api/Writer.collection.md) creates it anew, [`session.node(nodeId)`](../api/Writer.node.md) never goes stale) and check [`Part.exists`](../api/Part.exists.md) or [`Collection.disposed`](../api/Collection.disposed.md) before a write you keep.

```ts
const legs = session.collection('legs', { role: 'product' });
if (!legs.disposed) await legs.set({ items: [] });
```

## Where the declaration names it

- [`Collection.disposed`](../api/Collection.disposed.md): True once disposed: writes then do nothing, record 'handle-disposed' and resolve 'refused' with reason 'disposed'; `load()` starts nothing and rejects AbortError (spec section 3.4).
- [`Collection.load`](../api/Collection.load.md): On a disposed collection it starts nothing, records 'handle-disposed' and rejects AbortError, which fails no transaction (spec section 3.4).
- [`Collection.part`](../api/Collection.part.md): While it doesn't exist, a write through it does nothing and records 'handle-disposed' ([`Part.exists`](../api/Part.exists.md)): for an item a pending `set()` or `load()` will create, write through [`find({ collection, key })`](../api/Writer.find.md), a rule that stays pending until the item lands.
- [`Part.exists`](../api/Part.exists.md): A [`node()`](../api/Writer.node.md) handle's writes stay rules on its address, pending while a queued scene write loads the node ([`Writer.node`](../api/Writer.node.md)); through any other such part, writes do nothing, record 'handle-disposed' and resolve 'refused' with reason 'disposed'.
- [`PartActions.set`](../api/PartActions.set.md): No match records 'target-unmatched'; a removed part records 'handle-disposed' (a [`node()`](../api/Writer.node.md) handle never does: its write is a rule on the model's address).
- [`Placement.parent`](../api/Placement.parent.md): A [`Collection.load`](../api/Collection.load.md) whose parent has no part left at the load's own commit point (a swap queued before it whose asset lacks that part) places nothing, resolves with a part that reads `exists: false` and records 'handle-disposed'.
- [`Reason`](../api/Reason.md): - 'disposed': a new write through a disposed collection or naming one as its `owner`, or through a part that reads `exists: false` (never a [`node()`](../api/Writer.node.md) handle); nothing ran, `matched` is 0 without 'target-unmatched', and `problems` holds 'handle-disposed' (spec section 3.4).
- [`ReportFields.matched`](../api/ReportFields.matched.md): A write refused 'disposed' reports 0 and records 'handle-disposed' instead.
- [`Writer.node`](../api/Writer.node.md): It never records 'handle-disposed'.

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

## Recorded by

- the table row `operations/settlement/write-disposed-target` (`tables/operations.json`)
- the table row `failure-matrix/cases/owner-disposed-during-transaction` (`tables/failure-matrix.json`)
- the table row `failure-matrix/cases/write-disposed-target` (`tables/failure-matrix.json`)
- the table row `failure-matrix/errorCases/disposed-handle` (`tables/failure-matrix.json`)
- the table row `lifecycle/operations/create-content` (`tables/lifecycle.json`)
- the table row `lifecycle/operations/dispose` (`tables/lifecycle.json`)
