mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 23:49:03 +00:00
Follows supabase/supabase#53048. Part of [FE-4772](https://linear.app/supabase/issue/FE-4772/error-core-tagged-error-types-and-rough-fault-classification-in). ## What `normalizeEmptyBodyResponse` already tries to recover empty success bodies (original body, then one `no-store` refetch). When a JSON `GET` is still empty after that, it now throws `MalformedResponseError` (reason `empty_body`) carrying `endpoint`, `method`, `requestId` and status, instead of resolving with `{}`, which crashes components. * Unchanged: 204s, `HEAD`, non-`GET` requests and empty non-JSON responses keep the `Content-Length: 0` normalization. * Reporting: the error rejects like a network failure, so React Query gets the tagged instance and `reportQueryError` reports it once after the last retry. The refetch diagnostics are attached as Sentry context, and the standalone empty-body diagnostic event is skipped for this case to avoid double reporting. Recovered cases still send the diagnostic. * Routing: `MalformedResponse` moves to `SAMPLE_ALWAYS`. It is rare, and while we confirm the recovery path is sufficient every unrecovered case should be visible. * An abort during recovery throws `RequestAborted`, not `MalformedResponse` ## Notes * Callers using `get()` directly outside React Query are not reported automatically, same as network errors. * No GET endpoint showed up as legitimately returning an empty JSON body in the existing empty-body diagnostics. ## Testing * `pnpm vitest run data lib components/interfaces/ErrorHandling state` passes. * Lint ratchet passes; `tsc` shows only a pre-existing error in `packages/ui-patterns` (`InstructionBlocks.tsx`).