Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughExternal DB sync endpoints (poller and sequencer) now support admin/internal authorization bypass, allowing privileged access without the CRON secret. The authorization header becomes optional in request schemas. A dashboard UI component adds manual force sync controls with trigger and cancellation capabilities, reloading status upon completion. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Client as Dashboard Client
participant Seq as Sequencer Endpoint
participant Poll as Poller Endpoint
participant Status as Status Reload
User->>Client: Click "Run Now" (force sync)
Client->>Client: Create AbortController
Client->>Seq: POST /sequencer (parallel)
Client->>Poll: POST /poller (parallel)
Seq-->>Client: Response
Poll-->>Client: Response
Client->>Status: Reload sync status
Status-->>Client: Updated status
Client->>Client: Reset forceSyncRunning, clear abort ref
Client-->>User: Display updated status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Greptile OverviewGreptile SummaryThis PR adds a "Force Sync" button to the external DB sync dashboard that allows admin users to manually trigger the sequencer and poller endpoints. Key Changes:
Architecture: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as Admin User
participant Dashboard as Dashboard UI
participant Poller as Poller Endpoint
participant Sequencer as Sequencer Endpoint
participant DB as Database
User->>Dashboard: Click "Run Now" button
Dashboard->>Dashboard: Create AbortController
Dashboard->>Dashboard: Set forceSyncRunning = true
par Parallel Sync
Dashboard->>Sequencer: GET /internal/external-db-sync/sequencer<br/>(with admin auth)
Sequencer->>Sequencer: Verify isAdmin OR CRON_SECRET
Sequencer->>DB: Backfill sequence IDs
Sequencer-->>Dashboard: Return {ok: true, iterations}
and
Dashboard->>Poller: GET /internal/external-db-sync/poller<br/>(with admin auth)
Poller->>Poller: Verify isAdmin OR CRON_SECRET
Poller->>DB: Claim pending requests
Poller-->>Dashboard: Return {ok: true, requests_processed}
end
Dashboard->>Dashboard: Load updated status
Dashboard->>Dashboard: Set forceSyncRunning = false
Dashboard-->>User: Display updated sync status
|
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/dashboard/src/app/`(main)/(protected)/projects/[projectId]/external-db-sync/page-client.tsx:
- Around line 346-375: The forceTriggerSync callback is calling the sequencer
and poller endpoints without stopWhenIdle, causing requests to hang up to
DEFAULT_MAX_DURATION_MS; update the endpoints used in forceTriggerSync (the
endpoints array and the sendRequest calls inside the map) to include the query
param stopWhenIdle=true (e.g. append "?stopWhenIdle=true" or use
URLSearchParams) so the backend stops immediately when idle; ensure
abortController.signal is still passed and keep error handling and loadStatus()
as-is.
🧹 Nitpick comments (1)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/external-db-sync/page-client.tsx (1)
759-761:saveFuseboxis an async function invoked directly inonClick— consider wrapping withrunAsynchronouslyWithAlert.
saveFuseboxis async and its errors are handled internally viasetError, but if an unexpected error is thrown (e.g., network failure beforeResult.fromPromiseis entered), it would become an unhandled promise rejection. Per coding guidelines, async handlers should be wrapped withrunAsynchronouslyWithAlertto avoid voided promises.Proposed fix
- <Button onClick={saveFusebox} disabled={!fuseboxDirty || savingFusebox} loading={savingFusebox}> + <Button onClick={() => runAsynchronouslyWithAlert(saveFusebox)} disabled={!fuseboxDirty || savingFusebox} loading={savingFusebox}>Based on learnings: "In the stack-auth codebase, use
runAsynchronouslyWithAlertfromstackframe/stack-shared/dist/utils/promisesfor async button click handlers and form submissions instead of manual try/catch blocks."
Summary by CodeRabbit
New Features
UI Improvements