auth-js
auth-js copied to clipboard
Error messages not being parsed correctly
recently we got a report from usage of supabase-js:
FetchError: invalid json response body at https://fscmlciotnxwjzflqzqs.supabase.co/auth/v1/admin/users reason: Unexpected token < in JSON at position 0
it's suspected that the error in question was either due to a failed request:
{
"code": 422,
"msg": "Email address already registered by another user"
}
// POST https://{REF}.supabase.in/auth/v1/admin/users
// HTTP/1.1 422 Unprocessable Entity
// Date: Thu, 26 May 2022 00:46:27 GMT
// Content-Type: application/json
// Content-Length: 69
or
Status
524
MethodPOST
Timestamp1653499427722000
IP Address173.70.226.178
Origin CountryUS
Clientsupabase-js/1.35.3
a 524 is a cloudflare specific error
we should try and reproduce both and make sure we are handling the errors correctly in the client
FetchError: invalid json response body ... can be observed when response.json() is called on a response that is not valid json. Both 1.22.22 and 1.23.0-next.16 do currently not catch this error.
See 1.23.0-next.16
https://github.com/supabase/gotrue-js/blob/67a6575102be9c50763ff5d06fd2ee44b18a69f3/src/lib/fetch.ts#L26-L28
PR #379 will catch this error and reject with an AuthUnknownError.
This has been fixed. Thank you @pixtron!