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

Supabase API calls not working after first one #333

Open
arthurmeb opened this issue Feb 17, 2024 · 0 comments
Open

Supabase API calls not working after first one #333

arthurmeb opened this issue Feb 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@arthurmeb
Copy link

arthurmeb commented Feb 17, 2024

My Supabase API calls stop working after the very first one. It will work as expected the first time, but any subsequent calls after that don't work. Try catch block doesn't return any errors. No logs in Supabase logs. Nothing, not even in the network tab.
I've tried with supabase.auth.signOut(), read from db and write to db. Nothing works after the first initial call.
So I can sign in, write to database, but if I try to any type of call again after that, it won't work. I have to refresh the page for it to work again, and even then it only works the first time.

I tried to fix it with add to my package.json
"overrides": {
"@supabase/supabase-js": "2.31.0",
"@supabase/gotrue-js": "2.43.1"
},

But this actually made things worse for me, now my app throws error
ERROR [worker reload] [worker init] Cannot find package '@supabase/supabase-js' imported from C:\Users[omitted][omitted][omitted].nuxt\dev\index.mjs
I was able to delete and reinstall package-lock.json and fix this error

Version

@nuxtjs/supabase: <! v1.1.4> // edit: changed to v1.1.6 and no changes
nuxt: <! v3.8.2>

Reproduction

    const incrementGens = async () => {

        if (user.value) {

            console.log('User logged in. Will write to db.') // stops here for every subsequent attempt after 1st one

            const { data, error: error2 } = await supabase
            .from('profiles')
            .update({ generations: currentGens - 1 })
            .eq('id', `${userProfileId.value}`)
            .select()

            if (error2) {
                console.error('Error updating generations:', error2);
            } else if (data) {
                console.log('Update successful:', data[0].generations);
            } 

Steps to reproduce

Login as a user
Make an API call to Supabase, should work
Try again, doesn't work

It's weird because it seems like it's only client side.
This bug doesn't happen when I'm not logged in as a user.
When not logged in, I still make writes to my bucket, and also writes to a database
But those run from my api routes, not from the client side
And they work fine

What is Expected?

Every subsequent API request after the first one should work, or atleast throw an error

What is actually happening?

No API requests after the first one work. They dont throw any errors, no logs in supabase dashboard, and don't even appear in network tab

@arthurmeb arthurmeb added the bug Something isn't working label Feb 17, 2024
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

1 participant