fix(builder): await pending graph writes before version save - #48
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Version POST snapshots the DB while canvas mutations may still be in flight, persisting stale checkpoints to Supabase. Track mutation fetches and flush them before save; route version panel through the shared save handler. Co-authored-by: esadrianno <esadrianno@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a race where manual version saves could snapshot stale database state while canvas mutations were still in flight.
Bug and impact
POST /api/workflows/{id}/versionsreads the workflow from the database. If the user hits Save (toolbar, ⌘S, or version panel) while a node drag, edge delete, or other graph PATCH is still pending, the saved version checkpoint does not match the canvas. With Supabase-backed version storage (PR #39), that stale snapshot is durable and restorable — restoring it drops newer edits.Root cause
handleSaveVersionand the version history panel's separate save path did not wait for in-flight graph mutation fetches before creating a version from the DB.Fix and validation
createPendingWriteTrackerto track in-flight graph mutation fetches.safeFetchcalls withtrackWrite.handleSaveVersionnow awaits pending writes before POSTing a version.onSavehandler.pnpm run test:run -- tests/lib/pending-writes.test.ts— pass (237 total tests).