OUT-4024: Move resync mechanisms to trigger.dev - #75
Conversation
Add @trigger.dev/sdk, @trigger.dev/build and @sentry/esbuild-plugin along with trigger:dev / trigger:deploy scripts, and ignore the local .trigger cache directory. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the failed-sync retry loop off the 300s Vercel function onto a trigger.dev scheduled task (cron every 6h, 3600s max duration), so it no longer times out as failed records grow. The task reuses the existing RetryFailedSyncsService unchanged. trigger.config.ts mirrors the quickbooks-sync setup (Sentry source-map upload, init and onFailure capture). It also stubs the `server-only` marker to an empty module in the esbuild build: unlike quickbooks-sync, this repo's service chain imports `server-only`, which throws when bundled outside Next's react-server condition and would crash the trigger worker at boot. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
trigger.dev now owns the resync schedule, so remove the Vercel cron entry, the /cron/retry-failed-syncs route and its controller, and the now-orphaned CRON_SECRET env var (its only consumer was that route). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Greptile SummaryThe PR moves failed-sync recovery from a Vercel HTTP cron to a Trigger.dev scheduled task, extending the available execution time while retaining the existing retry service.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code defect identified. The new scheduler delegates to the unchanged recovery service, and the removed Vercel entry point is replaced coherently by the Trigger.dev task and documented deployment requirements. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Trigger.dev six-hour schedule] --> B[processResyncForFailedRecords]
B --> C[RetryFailedSyncsService]
C --> D[Select eligible failed records]
D --> E[Replay through WebhookService]
E -->|Success| F[Delete failed record]
E -->|Failure| G[Retain record and increment attempts]
Reviews (1): Last reviewed commit: "refactor(OUT-4024): drop vercel cron ret..." | Re-trigger Greptile |
What & why
Closes OUT-4024.
The failed-sync retry ran as a Vercel cron (
/cron/retry-failed-syncs) whose handler executed the whole retry loop inline under a 300s functionmaxDuration. As failed records grow, that sequential loop risks timing out and never draining the backlog.This moves the retry off Vercel and onto a trigger.dev native scheduled task (cron every 6h, 3600s max duration). trigger.dev owns the schedule end-to-end, so the Vercel cron, route, and controller are removed entirely.
RetryFailedSyncsServiceitself is unchanged — just relocated.Changes
src/trigger/resyncFailedRecords.ts—schedules.task(cron: '0 */6 * * *',machine: 'small-2x') that callsRetryFailedSyncsService.retryFailedSyncs().trigger.config.ts— mirrors the quickbooks-sync setup:maxDuration: 3600, task-level retries, Sentry source-map upload +init+onFailure.vercel.jsoncron entry, and the now-orphanedCRON_SECRETenv var.@trigger.dev/sdk,@trigger.dev/build,@sentry/esbuild-pluginandtrigger:dev/trigger:deployscripts.server-onlystub (repo-specific)trigger.config.tsstubs theserver-onlymarker to an empty module in the esbuild build. Unlike quickbooks-sync, this repo's service chain importsserver-only(viaserver.env,db,CopilotAPI, …), which throws when bundled outside Next'sreact-servercondition and would crash the trigger worker at boot. Verified empirically that the bundle throws without the stub and loads with it.Verification
pnpm typecheck(app + test) ✅pnpm lint✅RetryFailedSyncsServicedirectly and are unaffected (not run here — needs Docker/testcontainers).pnpm trigger:devsmoke test still needs the trigger.dev project + env vars below.Deploy checklist (before go-live)
TRIGGER_PROJECT_IDandTRIGGER_SECRET_KEYpnpm trigger:deployto register the scheduled taskCOPILOT_API_KEY,DATABASE_URL,XERO_*,ASSEMBLY_ENV) plusVERCEL_ENV=productionand the Sentry vars (NEXT_PUBLIC_SENTRY_DSN,SENTRY_ORG,SENTRY_PROJECT,SENTRY_AUTH_TOKEN) — in both the deploy context and the runtime store🤖 Generated with Claude Code