-
Notifications
You must be signed in to change notification settings - Fork 14
stripe_worker not checking sync_job for error status, not syncing for 7 days after an error occurs. #189
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I just created a new Supabase project, a new Stripe account, and set up Stripe Sync Engine using the integrations UI on Supabase. The first sync job in the stripe_worker ran successfully for 9 tables, but failed for 9 tables due to throttling. The sync_runs view has the status error and the following error_message:
Initialization failed: Error: Request rate limit exceeded. You can learn more about rate limits here https://stripe.com/docs/rate-limits.;
Despite the job failing, whenever the stripe_worker Edge Function runs, it prints out a message such as:
Skipping resync — a successful run completed at 2026-03-28T13:54:11.659Z (within 604800s window). Cron paused until 2026-03-28T17:58:00.764Z.
This behavior is incorrect, as the run was not successful. When I look at the Edge Function code in my Supabase account, I see the following code:
const completedRun = await stripeSync.postgresClient.getCompletedRun(
stripeSync.accountId,
SYNC_INTERVAL
);
const message = `Skipping resync \u2014 a successful run completed at ${completedRun?.runStartedAt.toISOString()} (within ${SYNC_INTERVAL}s window). Cron paused until ${skipUntil}.`;
...
async getCompletedRun(accountId, intervalSeconds) {
const result = await this.query(
`SELECT r."_account_id", r.started_at
FROM "${this.syncSchema}"."_sync_runs" r
WHERE r."_account_id" = $1
AND r.closed_at IS NOT NULL
AND r.closed_at >= now() - make_interval(secs => $2)
LIMIT 1`,
[accountId, intervalSeconds]
);
if (result.rows.length === 0) return null;
const row = result.rows[0];
return { accountId: row._account_id, runStartedAt: row.started_at };
}This clearly shows that the code is not checking for the status of the sync job, it's only checking if a run completed within the last 7 days. In fact, the _sync_runs table it's checking doesn't even have a status column, that's only in the sync_runs view.
This leads to a problematic state where the stripe_worker will never error correct as long as any run has happened in the last 7 days.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create a new Supabase project, a new Stripe account, and set up Stripe Sync Engine using the integrations UI on Supabase.
- Get throttling errors (or any other service errors) from Stripe.
- stripe_worker will now skip syncing for 7 days.
Expected behavior
stripe_worker should check the status of the sync job, and if it's in an error state, it should run the sync job.
Screenshots
System information
- OS: macOS
- Browser: safari
- Version of supabase-js: N/A
- Version of Node.js: N/A
Additional context
getCompletedRun function
https://github.com/stripe/sync-engine/blob/main/packages/sync-engine/src/database/postgres.ts#L768
reconciliationRun comment says it should "run only if no run completed successfully in the last 24 hours", but relies on the getCompletedRun function, which only checks for a completed run, not a successfully completed run.
https://github.com/stripe/sync-engine/blob/main/packages/sync-engine/src/database/postgres.ts#L787


