fix(userscript): don't let a failing in-flight write clobber a deferred entry

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 17:38:49 +07:00
parent cfcac48df2
commit 66eb3d2a98
+10 -2
View File
@@ -554,7 +554,15 @@
}
ok = true;
} catch (e) {
queueEnqueue(key, "put", withStatus, e);
// Same guard as the success path: a newer write is parked for this key, so
// classifying *this* failure would clobber its op or, on a 400, drop it
// outright. Its own drain reports its own outcome. The one thing that must
// still carry across is sendStatus — this flight may have been the archive
// replay, and losing its flag here would narrow the parked write into a
// silent un-archive.
const parked = inFlight.get(key) ? queueGet(key) : null;
if (parked) queueDefer(key, parked.op, withStatus);
else queueEnqueue(key, "put", withStatus, e);
} finally {
inFlight.delete(key);
}
@@ -576,7 +584,7 @@
if (!inFlight.get(key)) queueDrop(key);
return true;
} catch (e) {
queueEnqueue(key, "delete", false, e);
if (!inFlight.get(key)) queueEnqueue(key, "delete", false, e); // see pushBookmark
return false;
} finally {
inFlight.delete(key);