usePacedMutations value regression while persisting #1060
Send to my agentKyleAMathews(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
KyleAMathews(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Thanks for the clear reproduction. I checked this again on current
main(bef12e24).In the linked
InputsBroken.tsx, the pacedmutationFnwaits forupdatePostto return{ txid }, but it does not wait for that transaction to arrive through Electric. The Collection's separateonUpdatehandler is not invoked by this paced mutation. That means the optimistic transaction can finish before the source update is acknowledged. A controlled replay on current main reproduced the reported fallback from the second optimistic value to the original value (0 → 1 → 2 → 0) when both handlers resolved before source acknowledgement.The paced handler needs to await Electric explicitly after the server write:
I also replayed same-row edits
0 → 1 → 2with handlers held until their source updates, using queue and debounce strategies. The debounce cases included the second write starting before the first acknowledgement. At every checkpoint after the second edit, both the Collection and an ordered, limited live-query Collection remained at2; the live-query callback after that edit reported only2. These are controlled core and live-query checks, not a full React/Electric/PostgreSQL host run.I’m closing this based on the documented
awaitTxIdhandler contract. If the rollback still occurs after adding that await to the pacedmutationFn, please reopen with the updated repro and the order of the returned txids and Electric stream messages. That would give us the missing legal-path trace to investigate.