'beforeCommit-threw' ​Contract 2.0.0 · package sha256
a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e· generated fromconfigurator-runtime.d.ts,tables/problems.jsonandservices/onsite-scripter/scripts/contract-docs-what-to-do.jsonbyservices/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.
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.
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 });
Session.beforeCommit: A throw undoes only its own writes, object by object as a savepoint's (spec section 6.1, O7), and records 'beforeCommit-threw'; the commit proceeds.The set is open: handle a code you don't know ('other').
failure-matrix/cases/before-commit-throws (tables/failure-matrix.json)hold/cases/case-5 (tables/hold.json)