DEV Community

Cojiroooo
Cojiroooo

Posted on

1

supabase.from().select() finished unexpectedly and doesn't occur any errors

Problem

I write the below, but it doesn't occur any errors and the process terminated prematurely.
At the first time after the server started, that was successful, but that happen after the reload browser.

supabase.auth.onAuthStateChange(async (event, session) => {
  // ...
  const { data, error } = await supabase.from("table_name").select(); // the process finished
  // ...
});
Enter fullscreen mode Exit fullscreen mode

Causes

I found the answer to this problem in the document.

Do not use other Supabase functions in the callback function. If you must, dispatch the functions once the callback has finished executing. Use this as a quick way to achieve this:

https://supabase.com/docs/reference/javascript/auth-onauthstatechange

Solution

I wanted to fetch the user information when users authentication was successful.

const afterSignedIn = async () => {
  const { data, error } = await supabase.from("users").select();
};

supabase.auth.onAuthStateChange((event, session) => {
  // ...
  setTimeout(() => {
    afterSignedIn();
  }, 0);
});


Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (2)

Collapse
 
buzz_garys_37a234856e81f4 profile image
Buzz Garys

This doesn't work

Collapse
 
cojiroooo profile image
Cojiroooo

Sorry for my late reply.
Can you tell me more details or logs??

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more