Skip to content

Supabase API calls not working after first one #333

Description

@arthurmeb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions