Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Updating row returns error code PGRST116 #431

@vladgardus

Description

@vladgardus

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

I encountered this issue only when the edge function I'm using is deployed. I've written some code where I insert a record and a few lines of code after I update the same record. It happens sometimes that updates return this error:

{
  code: "PGRST116",
  details: "Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row",
  hint: null,
  message: "JSON object requested, multiple (or no) rows returned"
}

This is in mainly the code compiled from multiple files:

import { Database } from '../../database.types.ts';
import { supabaseConfig } from './config.ts';
import { createClient } from '@supabase/supabase-js';
const supabaseClient = createClient<Database>(supabaseConfig.SB_URL, supabaseConfig.SB_KEY);
const chaptersDB = supabaseClient.from('chapter');
const { data: chapter, error } = await chaptersDB
  .insert({
    --columns here--
  })
  .select()
  .single();
const { id } = chapter;
const { error } = await chaptersDB.update({ --columns here-- }).eq('id', id);
const { error } = await chaptersDB.update({ --other columns here-- }).eq('id', id);

What am I doing wrong?

It feels like those queries run in different transactions and the first one doesn't end after the insert.

Do I need to somehow destroy the supabase client after each edge function execution? This does not happen right after deploying the function, but after a couple of runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions