Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting proper error message from PostgrestBuilder #488

Open
junedkhatri31 opened this issue Oct 21, 2023 · 1 comment
Open

Not getting proper error message from PostgrestBuilder #488

junedkhatri31 opened this issue Oct 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@junedkhatri31
Copy link

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

When fetch function inside PostgrestBuilder fails. The error does not contain proper information why the fetch failed.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Put postgrest server behind self signed certificate
  2. Run database query
    const { data: somedata, error } = supabase
        .from('sometable')
        .select('*')
        .order('somecolumn', { ascending: false })
    
  3. Getting error message like the below
    Screenshot 2023-10-21 at 22 58 43
  4. It is not very clear what the error is

Expected behavior

The error should contain clear information that the error is we are not able to verify certificate

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Browser (if applies): NextJS server component
  • Version of supabase-js: 2.25.0
  • Version of Node.js: 18.18.2

Additional context

After spending 2 hours digging through internal library I found out that the error is self signed certificate is not being verified properly (Self signed cert is added properly in container's /etc/ssl/certs/ca-certificates.crt path. That is also an issue but I will deal with it separately.)

The point is I found where exactly the problem is. It is in src/PostgrestBuilder.ts inside then function. res object's error contains another error named cause that contains more information about the error. Which is getting lost. Because it is not getting assigned in new error object.
Screenshot 2023-10-21 at 23 05 20

@junedkhatri31 junedkhatri31 added the bug Something isn't working label Oct 21, 2023
@deleted
Copy link

deleted commented Nov 3, 2023

This problem hit me too. There's not way to determine the cause of the fetch error or handle it.

I'd suggest either propogating the original error:

return {
  error: fetchError,
  data: null,
  ...
}

Or a new error encapsulating the original error in its cause property:

return {
  error: new Error("Fetch Failed", {cause: fetchError}),
  ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants