Problem code 'beforeCommit-threw' ​

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 · stable · since 2.0.0

A beforeCommit function threw, or was pending after 10 s; its writes were undone.

What to do ​

Fix the cause in your session.beforeCommit function (the Problem's message has it) and make it settle within 10 s: a throw, or a function still pending then, undoes only that function's own writes and the commit goes on without them. Let a failure escape rather than catch it half-way, which would keep the half-done writes, or catch it and write a complete fallback layout. The hook is labs: register it through has(session, 'beforeCommit') (has from the package root) with an on('committed') fallback, as below.

ts
has(session, 'beforeCommit') // either branch unregisters when `signal` aborts
  ? session.beforeCommit('layout', async (commit) => {
      try { await layout(commit.tx); } catch { await fallbackLayout(commit.tx); } // every node posed either way
    }, { signal })
  // keep this branch: a runtime without the labs hook gets the same writes, one frame later
  : session.on('committed', ({ recorded }) => { if (recorded) void layout(session); }, { signal });

Where the declaration names it ​

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

Recorded by ​