supabase icon indicating copy to clipboard operation
supabase copied to clipboard

`supabase.auth.admin.updateUserById()` return error `AuthRetryableFetchError status 504`

Open yudistiraashadi opened this issue 10 months ago • 1 comments

Bug report

  • [ x ] I confirm this is a bug with Supabase, not with my own application.
  • [ x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Calling supabase.auth.admin.updateUserById() return AuthRetryableFetchError status 504 but the data in DB (Supabase online) is correctly updated. Apparently the error happened if I add email as a parameter. I can change password and/or app_metadata without error. The data is updated in Supabase online, but I still receiver error. Note: I'm using Next.js with SSR.

To Reproduce

Here is my exact code:

export const createAdminClient = () => {
  const cookieStore = cookies();

  return createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_SERVICE_KEY!,
    {
      cookies: {
        get(name: string) {
          return cookieStore.get(name)?.value;
        },
        set(name: string, value: string, options: CookieOptions) {
          try {
            cookieStore.set({ name, value, ...options });
          } catch (error) {
            // The `set` method was called from a Server Component.
            // This can be ignored if you have middleware refreshing
            // user sessions.
          }
        },
        remove(name: string, options: CookieOptions) {
          try {
            cookieStore.set({ name, value: "", ...options });
          } catch (error) {
            // The `delete` method was called from a Server Component.
            // This can be ignored if you have middleware refreshing
            // user sessions.
          }
        },
      },
    },
  );
};
const supabaseAdmin = createAdminClient();

const { data: updateUserData, error: updateUserError } =
  await supabaseAdmin.auth.admin.updateUserById(result.data.id, {
    email: result.data.username + "@email.com",
    password: result.data.password,
  });

console.log({ updateUserData, updateUserError });

The resulting data and error:

{
  updateUserData: { user: null },
  updateUserError: AuthRetryableFetchError: {}
      at handleError (webpack-internal:///(action-browser)/./node_modules/@supabase/auth-js/dist/module/lib/fetch.js:38:15)
      at _handleRequest (webpack-internal:///(action-browser)/./node_modules/@supabase/auth-js/dist/module/lib/fetch.js:120:15)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async _request (webpack-internal:///(action-browser)/./node_modules/@supabase/auth-js/dist/module/lib/fetch.js:99:18)
      at async GoTrueAdminApi.updateUserById (webpack-internal:///(action-browser)/./node_modules/@supabase/auth-js/dist/module/GoTrueAdminApi.js:201:20)
      at async eval (webpack-internal:///(action-browser)/./src/app/dashboard/user/_actions/edit-user.ts:81:70)
      at async scope (webpack-internal:///(action-browser)/./node_modules/postgres/src/index.js:257:18)
      at async Function.begin (webpack-internal:///(action-browser)/./node_modules/postgres/src/index.js:240:14)
      at async editUser (webpack-internal:///(action-browser)/./src/app/dashboard/user/_actions/edit-user.ts:76:9)
      at async /home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:418
      at async rS (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:38:7978)
      at async r2 (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:41:1251)
      at async doRender (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:1438:30)
      at async cacheEntry.responseCache.get.routeKind (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:1587:40)
      at async DevServer.renderToResponseWithComponentsImpl (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:1507:28)
      at async DevServer.renderPageComponent (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:1924:24)
      at async DevServer.renderToResponseImpl (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:1962:32)
      at async DevServer.pipeImpl (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:920:25)
      at async NextNodeServer.handleCatchallRenderRequest (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/next-server.js:272:17)
      at async DevServer.handleRequestImpl (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/base-server.js:816:17)
      at async /home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/dev/next-dev-server.js:339:20
      at async Span.traceAsyncFn (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/trace/trace.js:154:20)
      at async DevServer.handleRequest (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
      at async invokeRender (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/lib/router-server.js:174:21)
      at async handleRequest (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/lib/router-server.js:353:24)
      at async requestHandlerImpl (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/lib/router-server.js:377:13)
      at async Server.requestListener (/home/yudis/Codes/Works/Retas.io/unilever/monitoring-timbangan/node_modules/next/dist/server/lib/start-server.js:141:13) {
    __isAuthError: true,
    status: 504,
    code: undefined
  }
}

Expected behavior

Return with no error since the data is correctly updated in Supabase online.

System information

  • OS: Ubuntu 22.04
  • Browser (if applies): Chrome
  • Version of supabase-js: 2.42.4
  • Version of supabase-ssr: 0.3.0
  • Version of Node.js: 18.19.0

Additional context

I'm using Next.js and Supabase SSR

yudistiraashadi avatar Apr 19 '24 02:04 yudistiraashadi

Hi! I can take a look at this, can you provide some more information as to why the error is occurring? Specifically I am looking for the Logs -> Infrastructure -> Auth tab and the entry with the 504. I am able to update my own test user without an issue, I may be missing some more context about the user like some email/password violation.

simonha9 avatar May 04 '24 14:05 simonha9

Hi all, We’re going to close this one due to inactivity. Please feel free to reopen if you’re still having issues here or open a new issue.

Hallidayo avatar Jun 09 '24 21:06 Hallidayo