Skip to content

Refuse a sync request while that project is already syncing - #2960

Merged
hahn-kev merged 1 commit into
developfrom
feat/sync-queue-result
Nov 10, 2026
Merged

hahn-kev merged 1 commit into
developfrom
feat/sync-queue-result

Conversation

@hahn-kev-bot

Copy link
Copy Markdown
Collaborator

AI summary

Summary

Second of three PRs split out of #2439. Before this change, asking FwHeadless to sync a project whose sync was already running got a 200, as though a sync covering the caller's changes had been queued. But the running sync may have read the repo before those changes were pushed. Now that request is refused with 429, so the caller retries once the running sync finishes.

 POST /api/merge/execute
   QueueJob(projectId)
-    returns bool, ignored → always 200
+    Queued              → 200
+    AlreadyQueued       → 200   (hasn't started, will pick up the caller's changes)
+    SyncAlreadyRunning  → 429   "A sync is already running for this project, try again once it has finished"
+    QueueFull           → 503   (was a false 200)

SyncHostedService now marks a queued sync as started when the worker takes it, which is how QueueJob tells "queued" from "running". The dictionary entry is still claimed with a single atomic GetOrAdd, so this needs no lock.

What users see (LexBox already passes FwHeadless 4xx responses through unchanged, since #2884):

  • Lexbox "Sync FieldWorks Lite" button: shows the 429 message.
  • FW Lite FieldWorks Classic sync view: error toast "Failed to synchronize" followed by the same message.

docs/site/technical/sync/fwheadless-merge.md is updated; it said re-triggering a running project was a no-op.

Evidence

SyncHostedServiceQueueTests (new):

QueueJob → Queued, QueueJob → AlreadyQueued                     ✅
QueueJob → Queued, MarkSyncStarted, QueueJob → SyncAlreadyRunning ✅
MarkSyncStarted with no sync → nothing tracked, next QueueJob → Queued ✅

Merge Danger

Door: two-way

Blast Radius: small

Clicking sync while that project's sync is running now shows "already running, try again" instead of quietly waiting on the running sync. FW Lite's automatic sync doesn't call this endpoint; only the manual FieldWorks Classic sync and the Lexbox button do.

Test plan

  • dotnet test backend/Testing --filter "FullyQualifiedName~SyncHostedServiceQueueTests|FullyQualifiedName~ProjectDeletionServiceTests": 10 passed

🤖 Generated with Claude Code

A sync request that arrived while the project's sync was already running
got a 200, as if a sync covering the caller's changes had been queued.
But the running sync may have read the repo before those changes were
pushed, so the caller could wrongly conclude its changes were synced.

QueueJob now returns a QueueJobResult and tracks whether a queued sync
has started. A request that finds the sync still waiting in the queue is
covered by it and still gets a 200; one that finds it already running
gets 429, and a full queue gets 503 instead of a false 200.

Split out of #2439.

Co-authored-by: Robin Munn <rmunn@pobox.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the 📦 Lexbox issues related to any server side code, fw-headless included label Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 952d2993-31ab-4fa3-89a3-24c74969adcd
Commits

Reviewing files that changed from the base of the PR and between 96730a3 and 94f3d19.

Files selected for processing: 4

  • backend/FwHeadless/Routes/MergeRoutes.cs
  • backend/FwHeadless/Services/SyncHostedService.cs
  • backend/Testing/FwHeadless/SyncHostedServiceQueueTests.cs
  • docs/site/technical/sync/fwheadless-merge.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@hahn-kev
hahn-kev merged commit 080358d into develop Nov 10, 2026
34 of 36 checks passed
@hahn-kev
hahn-kev deleted the feat/sync-queue-result branch November 10, 2026 07:23
myieye added a commit that referenced this pull request Nov 11, 2026
…sts (#2966)

Since #2960, re-triggering a sync that's already running returns 429, so both DuringSyncInProgress tests in DeleteProjectTests failed on their second trigger. A 429 there is the state the tests want, so the re-trigger now accepts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 Lexbox issues related to any server side code, fw-headless included

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants