fix(rc-entitlement-drift-check): extend cron pg_net timeout to 60s#70
Conversation
The drift check runs ~30s with the current profile count (sequential per-customer RC fetches), which exceeds pg_net's default 5s timeout. The function itself completed correctly on every fire — Sentry events fired, heartbeats logged — but net._http_response.status_code stayed NULL for cron-triggered runs, making the cron's success/failure invisible in pg_net's response table. Uses cron.alter_job to replace just the command text on the existing jobid; schedule and lock-table behavior are unchanged. Surfaced during the first real smoke test of PR #68's per-profile-fetch refactor — the manual invocation at request_id=37 hit the 5s timeout even though the function ran to completion, while request_id=38 with an explicit 60s pg_net timeout returned status_code=200 correctly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
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 |
) - Build command was iOS-only; reality is `eas build --platform <ios|android>` plus the `npm run build:*` aliases. - Architecture line listed payments as iOS-only; the app supports Google Play Billing too (see docs/payments.md). - Removed reference to docs/technical-plan.md — file doesn't exist. - Added drift_check_runs to the table quick-reference. - Added a one-liner under IMPORTANT documenting the pg_cron + supabase_vault pattern introduced in #60/#68/#70, so future work follows the same shape instead of re-deriving it. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Observability follow-up to #60 / #66 / #68.
Summary
The drift check function takes ~30 seconds with the current profile count because per-customer RC fetches are sequential, but the cron migration's `net.http_post` call uses pg_net's default 5-second timeout. The function ran to completion on every fire (Sentry events, heartbeat logs all worked) but `net._http_response.status_code` was always recorded as `NULL` for cron-triggered runs, making the cron's success state invisible from SQL.
This migration uses `cron.alter_job` to replace just the command text on the existing scheduled job, keeping the schedule, jobid, and lock-table behavior identical. Function behavior is unchanged.
How this surfaced
During the first real smoke test of #68:
The fix is to make cron behave like request 38.
Test plan
After merging:
`git pull && supabase db push`
In the SQL editor, confirm the cron command was updated:
Wait for the next `:17 mod 6h` UTC scheduled fire, then check:
Follow-up
None.