Keep a newer queue change over a queue reply it overtook

A QueueEvent arriving in the same socket read as a QueueSyncRequest reply is
applied before the reply, which then wrote the older queue over it. Skip the
reply when a QueueEvent was applied while it was in flight.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ILLISISandClaude Opus 5.5 committed 2026-10-20 12:20:36 +11:00
1 parent fd39e2a171
commit b10807b6d6
2 files changed
+19

No files matched your search

+11
View File
@@ -117,6 +117,17 @@ describe("research_sync instance", function() {
instance.sendTo = async () => { throw new Error("gone"); };
await instance.hooks.controllerConnectionEvent.invoke("connect");
});
it("should not let the reply overwrite a newer QueueEvent delivered with it", async function() {
// As if the reply and the broadcast came in one socket read: the event is handled before the
// reply resolves the request's await
instance.sendTo = async (dst, message) => {
sent.push(message);
mock.getHandler(instance, QueueEvent)(new QueueEvent(["new"], null, "B"));
return ["old"];
};
await instance.hooks.controllerConnectionEvent.invoke("connect");
assert.equal(lastCommand(), applyCommand({ queue: ["new"], instance: "B" }));
});
});
it("should forward queue changes from the game", async function() {