Repository navigation
Fix rate-limit overrides, AI error reports, and the login crash - #190
Conversation
Rate-limit lookups ordered by updated_at, which production does not have, so every override was ignored. Order by created_at and log the lookup failure. The new migration is not applied. Network failures are AINetworkError and stay out of Sentry. Unknown failures are AIUnknownError with a privacy-safe cause type. Other HTTP 5xx responses are AIServerError. A 401 or 403 from getUser signs out once and stops store reloads. Missing rows use maybeSingle. Edge Stripe uses the npm worker build and the fetch client. Optional analytics chunks no longer crash /login when a preload resolves to undefined. Fixes JAVASCRIPT-REACT-6 Fixes JAVASCRIPT-REACT-9 Co-authored-by: Gáborjáni-Szabó Ádám <Programcode@users.noreply.github.com>
|
Deployment failed for project debate-navigator with the following error: Learn More: https://vercel.com/adam-gaborjanis-projects?upgradeToPro=build-rate-limit |
ℹ️ Recent review info
📝 Walkthrough
Note 🎁 Summarized by CodeRabbit Free
Comment |
Fixes JAVASCRIPT-REACT-6
Fixes JAVASCRIPT-REACT-9
Rate-limit overrides
rate_limitslookups ordered byupdated_at. Production only hascreated_at, so PostgREST returned 400 and the client ignored it. Per-account and globaldaily_requestsoverrides never applied. Voice uses the same helper.Lookups now order by
created_at. A failed lookup logs a server-side warning without the user id and falls back. The admin limits action uses the same column. New migrationsupabase/migrations/20261022140000_rate_limits_order_by_created_at.sqlreplacesget_active_rate_limitsto order bycreated_at, thenid. This migration is in the PR and is not applied.Tests reject any
rate_limitsquery whoseordercontainsupdated_at, and cover per-user over global over fallback, plus the logged error.AI errors (JAVASCRIPT-REACT-6)
Network failures (
Failed to fetch, Firefox/Safari network messages, or the browser offline) becomeAINetworkError. The product eventai_request_failedstill fires. Sentry does not. Unknown failures becomeAIUnknownErrorand Sentry gets a privacy-safe cause type (name:Constructor), never the message. 402, 403, and timeouts are unchanged. Offline copy is in en, es, and hu.Brainstorm AIError at 17:08 Budapest (JAVASCRIPT-REACT-7)
Distinct from the network issue. One handled event on
/app/brainstormat 15:08 UTC, release34fb5856,statusCode500,durationMs1882, featurebrainstorm. On that release,mapAIErroralso stamped status 500 when no HTTP status existed, so the Sentry title wasAIError: AIErroreither way.A body with
code: provider_errorstaysAIProviderError. Any other real 5xx is nowAIServerError(still captured, with its status). A failure with no HTTP status is no longer given status 500.Dead session refetch
getUser()401 or 403 signs out once with{ scope: 'local' }, blocks a restoredSIGNED_INfrom hydrating again, andRequireAuthsends the tab to/login. REST 401 still refreshes once. Refresh outages use backoff from 1s to 60s. A throwngetUser(outage) keeps the local session. Stub browser sessions now answerGET /auth/v1/userso a render check is not signed out.406 noise
checkUserBannedandgetGlobalPromptusemaybeSingle(). No row still means not banned and a null prompt. Tests check the no-row path and thatAcceptdoes not demandapplication/vnd.pgrst.object+json.Stripe
Deno.core.runMicrotasks()create-checkoutandaccountimportedstripefrom esm.sh with?target=deno, which pulledstd@0.177.1process.nextTick. That callsDeno.core.runMicrotasks()after the response. Checkout sessions were still created.Shared
createEdgeStripeimportsnpm:stripe@14.10.0(worker build) and keepsStripe.createFetchHttpClient(). The same import was increate-portalandstripe-webhook, so those use it too.npm run test:edgepasses--node-modules-dir=auto. A test checks the fetch client name and that the Node client throws. Edge Functions are not deployed.Login crash (JAVASCRIPT-REACT-9)
Unhandled
TypeError: (destructured parameter) is undefinedon/login, three events, release34fb5856. The stack is the lazy import of@vercel/analytics/react: Vite resolves a prevented preload error toundefined, and.then(({ Analytics }) => …)throws. The event Sentry returned is Firefox 157 on Linux, timezone Europe/Budapest, zero users.SpeedInsightshad the same destructure. A missing analytics chunk now renders nothing instead of taking down the page.Verification
npm run verifypassed locally on this commit: docs check, lint, typecheck, 422 unit tests, 30 collaboration tests, edge tests, build, service-worker check, and 43 desktop Chromium@smoketests. This is a local pass, not a GitHub Actions result.Summary by CodeRabbit