fix(kanban): fail closed on persistence errors

req: sync/015
This commit is contained in:
slhx agent
2026-07-13 15:11:08 +02:00
parent d946975f2d
commit 47715e3ba3
3 changed files with 184 additions and 9 deletions
+19 -5
View File
@@ -85,10 +85,21 @@ async function appendReorder(database, wire) {
};
meta.put(actor, "actor");
meta.put(causal, "causal");
commands.add(command);
const count = await result(commands.count());
await done;
return { command, count };
const append = result(commands.add(command));
const counted = result(commands.count());
const completion = done.then(
() => null,
(error) => error,
);
try {
const [, count] = await Promise.all([append, counted]);
const transactionError = await completion;
if (transactionError) throw transactionError;
return { command, count };
} catch (error) {
await completion;
throw error;
}
}
async function storedCommands(database) {
@@ -122,9 +133,12 @@ async function project(root, wasmHandler, command) {
}
function report(root, stage, error) {
const code = error && typeof error.name === "string" ? error.name : "Error";
const message = error instanceof Error ? error.message : String(error);
root.setAttribute("data-kanban-command-error", `${stage}: ${message}`);
root.dispatchEvent(new CustomEvent("kanban:command-error", { detail: { stage, message } }));
root.setAttribute("data-kanban-command-error-stage", stage);
root.setAttribute("data-kanban-command-error-code", code);
root.dispatchEvent(new CustomEvent("kanban:command-error", { detail: { stage, code, message } }));
}
function announce(root, message) {