# Problem code `'write-after-close'`

> 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 write through a closed `tx` or its handles (HoloTransactionClosedError).

## What to do

A `tx` takes writes only while its transaction is open: make and await every write inside the `work` of [`session.transaction(work)`](../api/Session.transaction.md), never keep `tx` or its handles, and write through `session` after the transaction resolves.

```ts
await session.transaction(async (tx) => { await tx.select(group, first); });
await session.select(group, second);
```

## Where the declaration names it

- [`HoloTransactionClosedError`](../api/HoloTransactionClosedError.md): Thrown at the call; nothing changes; the problem 'write-after-close' is recorded (after [`destroy()`](../api/Session.destroy.md), `closedBy` is 'destroyed' and nothing is recorded; after `el` leaves the document, `closedBy` is 'aborted' and nothing is recorded (spec section 6.5); nor through a [`beforeCommit`](../api/Session.beforeCommit.md) hook's `commit.tx` whose commit ended before its commit point).

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

## Recorded by

- the table row `failure-matrix/cases/write-through-closed-tx` (`tables/failure-matrix.json`)
- the table row `failure-matrix/errorCases/write-through-closed-tx` (`tables/failure-matrix.json`)
