Skip to content

Conversation

@ubik2
Copy link
Contributor

@ubik2 ubik2 commented Sep 17, 2025

  • If we revert a result cell (or get some other server driven change), our closure captured initializedUpTo state will be out of sync. If this means it points after the last element, re-initialize the missing elements.

Summary by cubic

Prevents the map builtin from reading past the result array after a rollback or server-driven change. We clamp initializedUpTo to the current length and re-init missing cells to keep results consistent.

  • Bug Fixes

    • Clamp initializedUpTo to result length when the result shrinks.
    • Re-initialize needed cells so appended items are processed correctly.
  • Refactors

    • Remove unnecessary any cast from op.getRaw() to improve type safety.

…result.

- If we revert a result cell (or get some other server driven change), our closure captured initializedUpTo state will be out of sync. If this means it points after the last element, re-initialize the missing elements.
@ubik2
Copy link
Contributor Author

ubik2 commented Sep 17, 2025

We re-run the opRecipe initialization in this revert scenario, which may already be running, but I think that's fine.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

// .getRaw() because we want the recipe itself and avoid following the
// aliases in the recipe
const opRecipe = op.getRaw() as any;
const opRecipe = op.getRaw();
Copy link
Contributor Author

@ubik2 ubik2 Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removed unneeded cast here. op is already Cell<any>.

@ubik2 ubik2 merged commit 95a1674 into main Sep 18, 2025
7 checks passed
@ubik2 ubik2 deleted the robin/speculative-map-fix branch September 18, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants