[BUG] Realtime confirms a block or variable edit before it is stored, so a failed write loses it

Open
#10,712 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start with apps/realtime/src/handlers/subblocks.ts and variables.ts, tracing how a flush handles pending edits, confirmations, failures, and actor IDs. Reproduce the overlap with two tabs and a failed write, then check that each edit settles only after its own write and collaborators see the stored value with the correct audit actor.

Written by the indexing model from the issue text.

Description

Describe the bug
When an edit to a subblock or variable field arrives while the previous edit of that field is being written, it joins that write's operation list. The earlier write confirms it before its value is stored. If its own write then fails, the client has already dropped the operation and ignores the failure, so the edit is lost while the UI still shows it. In the same overlap the first editor can be left showing a stale value, a later edit can be dropped without an answer, and the variable audit log can name the wrong user.

To Reproduce

  1. Open the same workflow in two tabs or as two users on the same realtime pod.
  2. Edit the same field in both, with B's edit arriving while A's write is in progress (a slow database widens the window).
  3. Make B's write fail, for example by locking the block.
  4. B sees the edit as saved, but it is not stored.

Expected behavior
Each edit is confirmed or failed only after its own write settles, every collaborator ends with the stored value, no edit is silently dropped, and the audit actor is the user who made the change.

Additional context
apps/realtime/src/handlers/subblocks.ts and variables.ts: a flush reads pending.latest when it starts but reads opToSocket and actorId at the end, and deletes the map entry after a newer edit may be using it.

Dominant language
TypeScript
Stars
29.8k
Forks
3.9k
Avg merge
1h 43m
Merged PRs (30d)
937

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simstudioai/sim

All issues in simstudioai/sim

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.