on master help sign in
Fix race effect-row unification in doPoll by padding arms with shared effects
commit7a97d105d83992036add52da505f3f4fcb3a332c authoriko <mail@iko.soy> dateMon 11 May 2026, 14:44 (5 months ago) parent5cc044c
1 file changed+12−5
server.knot+12−5
server.knot+12−5
@@ -649,12 +649,19 @@ doPoll = \s t -> do
649649 if count initial.events > 0
650650 then yield initial
651651 else do
652+ -- `race` requires both arms to share a single effect row, so each arm
653+ -- carries the union {r *messages, clock} — the STM wait gets a `now`,
654+ -- the timer gets a no-op `*messages` read.
652655 race
653− (atomic (do
654− msgs <- *messages
655− let fresh = filter (\m -> m.toKey == s.pubkey && m.receivedAt > s.clampedCursor) msgs
656− if count fresh > 0 then yield {} else retry))
657− (sleep pollTimeoutMs)
656+ (do
657+ _ <- now
658+ atomic (do
659+ msgs <- *messages
660+ let fresh = filter (\m -> m.toKey == s.pubkey && m.receivedAt > s.clampedCursor) msgs
661+ if count fresh > 0 then yield {} else retry))
662+ (do
663+ atomic (do _ <- *messages; yield {})
664+ sleep pollTimeoutMs)
658665 t2 <- now
659666 collectAt t2
660667