fix(kanban): recover from quota exhaustion
req: sync/015
This commit is contained in:
@@ -67,6 +67,10 @@ function stableSession() {
|
||||
async function appendReorder(database, wire) {
|
||||
const transaction = database.transaction([COMMANDS, META], "readwrite");
|
||||
const done = completed(transaction);
|
||||
const completion = done.then(
|
||||
() => null,
|
||||
(error) => error,
|
||||
);
|
||||
const meta = transaction.objectStore(META);
|
||||
const commands = transaction.objectStore(COMMANDS);
|
||||
const actorRequest = result(meta.get("actor"));
|
||||
@@ -85,14 +89,18 @@ async function appendReorder(database, wire) {
|
||||
eventKind: String(wire[1] || "click"),
|
||||
key: wire[4] ? String(wire[4]) : null,
|
||||
};
|
||||
meta.put(actor, "actor");
|
||||
meta.put(causal, "causal");
|
||||
const append = result(commands.add(command));
|
||||
const counted = result(commands.count());
|
||||
const completion = done.then(
|
||||
() => null,
|
||||
(error) => error,
|
||||
);
|
||||
let append;
|
||||
let counted;
|
||||
try {
|
||||
meta.put(actor, "actor");
|
||||
meta.put(causal, "causal");
|
||||
append = result(commands.add(command));
|
||||
counted = result(commands.count());
|
||||
} catch (error) {
|
||||
transaction.abort();
|
||||
await completion;
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
const [, count] = await Promise.all([append, counted]);
|
||||
const transactionError = await completion;
|
||||
|
||||
Reference in New Issue
Block a user