summaryrefslogtreecommitdiff
path: root/ui/lib/runs.js
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-05-06 01:07:54 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-05-06 01:26:27 -0400
commite4273ffd945f16d6f74e9c64431808ea36148880 (patch)
tree336758ee57f7c4fa5a53002d8082b8e1978496d5 /ui/lib/runs.js
parentadc1aef3dbc6b9d5f08f215d527a37e7cc59ddd9 (diff)
Render "ghost" messages for unsent messages.
There is a subtle race conditon in this code, which is likely not fixable without a protocol change: * Ghost messages can disappear before their "real" message replacement shows up, if the client finishes sending (i.e., receives an HTTP response on the POST) before the server delivers the real message. * Ghost messages can be duplicated briefly, if the client receives the real message before the client finishes sending. Both happen in practice; we make no ordering guarantees between requests. To aviod this, we'd to give clients a way to correlate pending sends with received messages. This would require fundamentally the same capabilities, like per-operation nonces, that preventing duplicate operations will require.
Diffstat (limited to 'ui/lib/runs.js')
-rw-r--r--ui/lib/runs.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/lib/runs.js b/ui/lib/runs.js
index f4e90be..e3d4c20 100644
--- a/ui/lib/runs.js
+++ b/ui/lib/runs.js
@@ -21,5 +21,13 @@ function runKey(message) {
}
function continueRun([lastSender, lastAt], [newSender, newAt]) {
- return lastSender === newSender && newAt - lastAt < RUN_COALESCE_MAX_INTERVAL;
+ const { id: lastId, name: lastName } = lastSender;
+ const { id: newId, name: newName } = newSender;
+ if (lastId !== newId) {
+ return false;
+ }
+ if (lastName !== newName) {
+ return false;
+ }
+ return newAt - lastAt < RUN_COALESCE_MAX_INTERVAL;
}