get-convex / get-convex/prosemirror-sync

getSnapshot and latestVersion are not sync

Open
#114 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
62
Forks
21
Avg merge
5h 25m
Merged PRs (30d)
1

Description

The results from the versionFromSnapshot query and the latest version query are identical before a manual snapshot is submitted. However, after executing them multiple times, their results diverge.

I know this is related to Convex query caching. I’m not certain if this is the intended behavior or a bug. It will be nice if someone can briefly explain why the result diverges.

Here is the code
```ts
export const parentAdaptSnapshot = async (
ctx: AuthMutationCtx,
parentResolutionId: ResolutionId,
resolutionId: ResolutionId,
) => {
const snapshot = await ctx.runQuery(
api.components.resolutionProsemirror.getSnapshot,
{ id: resolutionId },
);

if (!snapshot.content) throw new ConvexError("Snapshot not found");

const parentSnapshot = await ctx.runQuery(
api.components.resolutionProsemirror.getSnapshot,
{ id: parentResolutionId },
);

const incorrectParentVersion = await ctx.runQuery(
components.resolutionProsemirrorSync.lib.latestVersion,
{ id: parentResolutionId },
);

console.log("parentSnapshot", parentSnapshot.version);

console.log("incorrectParentVersion", incorrectParentVersion);

if (!parentSnapshot.content)
throw new ConvexError("Parent snapshot not found");

const newParentVersion = (parentSnapshot as { version: number }).version + 1;

await ctx.runMutation(
components.resolutionProsemirrorSync.lib.submitSnapshot,
{
id: parentResolutionId,
version: newParentVersion,
content: snapshot.content,
},
);

return snapshot;
};
```
```
8/14/2025, 6:58:18 PM [CONVEX M(fn/resolutions/state:declareVoteResult)] [LOG] 'parentSnapshot' 12
8/14/2025, 6:58:18 PM [CONVEX M(fn/resolutions/state:declareVoteResult)] [LOG] 'incorrectParentVersion' 12
8/14/2025, 6:58:38 PM [CONVEX M(fn/resolutions/state:declareVoteResult)] [LOG] 'parentSnapshot' 13
8/14/2025, 6:58:38 PM [CONVEX M(fn/resolutions/state:declareVoteResult)] [LOG] 'incorrectParentVersion' 12
```

Contributor guide

Open the contributing guide

Research direction

Start with parentAdaptSnapshot and compare the getSnapshot/versionFromSnapshot path with components.resolutionProsemirrorSync.lib.latestVersion. Reproduce the logged version mismatch after repeated queries and inspect how Convex query caching affects the subsequent submitSnapshot mutation. Done means explaining whether the divergence is intended or identifying the consistency bug and its affected entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.