Upgrade to new API Key (Could not query the database for the schema cache. Retrying.)

Since I upgrade to the PostG version and migrate to the new API KEY replacing the Legacy.

Result:
Error: Test user client cannot access tenants table: Could not query the database for the schema cache. Retrying.

From:
async function createTestUser(prefix) {
    const email = `${prefix}${randomName()}@example.com`;
    const password = 'TestPass123!';
    const {data, error} = await supabaseClient.auth.admin.createUser({
        email,
        password,
        email_confirm: true,
    });
    if (error) {
        throw new Error(`Error creating ${prefix}: ${error.message}`);
    }
    const token = await signInTestUser(email, password);

    const client = createAuthClient(token);
    // Validate that the client can access the tenants table
    const {error: accessError} = await client.from('tenants').select('id').limit(1);
    if (accessError) {
        throw new Error(`Test user client cannot access tenants table: ${accessError.message}`);
    }
    return {id: data.user.id, email: data.user.email, token, client};
}

function createAuthClient(token) {
    return createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY, {
        global: {
            headers: {Authorization: `Bearer ${token}`},
        },
    });
}


What I tried:
  • Disabled all RLS
  • Use old KEY
  • Restart the server
    -Clear cash: NOTIFY pgrst, 'reload schema'
The table exist and row exist as well.

Any help is welcome, I'm stuck since hours.
Was this page helpful?