Skip to content

fix(#243): replace findUnique+create with upsert for SyncState init#275

Merged
Ultra-Tech-code merged 2 commits into
Afristore:masterfrom
Biokes:fix/243-syncstate-upsert
May 31, 2026
Merged

fix(#243): replace findUnique+create with upsert for SyncState init#275
Ultra-Tech-code merged 2 commits into
Afristore:masterfrom
Biokes:fix/243-syncstate-upsert

Conversation

@Biokes
Copy link
Copy Markdown
Contributor

@Biokes Biokes commented May 31, 2026

  • Capture the return value of prisma.syncState.update when resetting to windowFloor and assign it back to syncState so the rest of the current iteration uses the persisted value, not the stale in-memory one.
  • Fix duplicate import and unclosed it-block in poller.test.ts.
  • Add test: simulate stale ledger range and verify events are fetched from window floor.

Closes #243

…te init

- Two instances starting simultaneously could both see no row and both
  attempt prisma.syncState.create, causing a unique constraint violation.
- Replace the findUnique + create pattern with a single upsert call
  (create if absent, no-op update if present) which is atomic and safe
  under concurrent startup.
- Add upsert mock to test helpers and a test verifying the new pattern.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@Biokes is attempting to deploy a commit to the ultratechcode's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@Biokes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ultra-Tech-code Ultra-Tech-code merged commit 2eef502 into Afristore:master May 31, 2026
0 of 6 checks passed
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.

Multi-instance race condition on SyncState creation

2 participants