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

server/api breaks when used with nuxt v3.1.x #151

Closed
sduduzog opened this issue Feb 7, 2023 · 13 comments
Closed

server/api breaks when used with nuxt v3.1.x #151

sduduzog opened this issue Feb 7, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@sduduzog
Copy link

sduduzog commented Feb 7, 2023

Here's the logs I got before downgrading nuxt to v3.0.0

[nuxt] [request error] [unhandled] [500] main.createClient is not a function
  at serverSupabaseServiceRole (/C:/dev/gits-web/.output/server/chunks/serverSupabaseServiceRole.mjs:10:33)
  at /C:/dev/gits-web/.output/server/chunks/transactions.post.mjs:13:17
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async Object.handler (/C:/dev/gits-web/.output/server/node_modules/h3/dist/index.mjs:840:19)
  at async Server.toNodeHandle (/C:/dev/gits-web/.output/server/node_modules/h3/dist/index.mjs:915:7)
[nuxt] [request error] [unhandled] [500] main.createClient is not a function
  at serverSupabaseServiceRole (/C:/dev/gits-web/.output/server/chunks/serverSupabaseServiceRole.mjs:10:33)
  at /C:/dev/gits-web/.output/server/chunks/transactions.delete.mjs:22:17
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async Object.handler (/C:/dev/gits-web/.output/server/node_modules/h3/dist/index.mjs:840:19)
  at async Server.toNodeHandle (/C:/dev/gits-web/.output/server/node_modules/h3/dist/index.mjs:915:7)

Version

@nuxtjs/supabase: v0.3.0
nuxt: v3.1.2

@sduduzog sduduzog added the bug Something isn't working label Feb 7, 2023
Copy link
Collaborator

larbish commented Feb 7, 2023

Can you try with the last version of the module ? If you are still experiencing this error, please provide a reproduction 🙏

@larbish larbish self-assigned this Feb 7, 2023
@sduduzog
Copy link
Author

sduduzog commented Feb 8, 2023

I'll give it a shot later today (CAT timezone) . I did start on setting up a reproduction repo but I haven't been lucky in reproducing the issue, whether the update works or not, I'll close this issue very shortly

@sduduzog
Copy link
Author

sduduzog commented Feb 9, 2023

I'll close this until I'm able to reproduce, But I suspect this is most likely issues around tooling

@sduduzog sduduzog closed this as completed Feb 9, 2023
@blackspike
Copy link

blackspike commented Feb 9, 2023

Oh! I have the EXACT same error as @sduduzog – I followed his advice and downgraded nuxt from 3.1.2 to 3.0.0 and it started working again

  "devDependencies": {
    "@nuxtjs/supabase": "^0.3.1",
    "@volar/vue-language-plugin-pug": "^1.0.24",
    "nuxt": "^3.1.2",
    "pug": "^3.0.2",
    "sass": "^1.58.0"
  },
Listening http://[::]:3000
[nuxt] [request error] [unhandled] [500] main.createClient is not a function
  at serverSupabaseClient (./.output/server/chunks/default-feeds.get.mjs:13:33)  
  at ./.output/server/chunks/default-feeds.get.mjs:113:18  
  at ./.output/server/node_modules/h3/dist/index.mjs:934:47  
  at async Object.handler (./.output/server/node_modules/h3/dist/index.mjs:990:19)  
  at async toNodeHandle (./.output/server/node_modules/h3/dist/index.mjs:1065:7)  
  at async ufetch (./.output/server/node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async $fetchRaw2 (./.output/server/node_modules/ofetch/dist/shared/ofetch.5cb01515.mjs:142:24)  
  at async setup (./.output/server/chunks/app/server.mjs:9268:125)
[nuxt] [request error] [unhandled] [500] main.createClient is not a function
  at serverSupabaseClient (./.output/server/chunks/default-feeds.get.mjs:13:33)  
  at ./.output/server/chunks/default-feeds.get.mjs:113:18  
  at ./.output/server/node_modules/h3/dist/index.mjs:932:14  
  at Object.handler (./.output/server/node_modules/h3/dist/index.mjs:1175:12)  
  at Object.handler (./.output/server/node_modules/h3/dist/index.mjs:990:31)  
  at async toNodeHandle (./.output/server/node_modules/h3/dist/index.mjs:1065:7)  
  at async ufetch (./.output/server/node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async $fetchRaw2 (./.output/server/node_modules/ofetch/dist/shared/ofetch.5cb01515.mjs:142:24)  
  at async setup (./.output/server/chunks/app/server.mjs:9268:125)

@sduduzog
Copy link
Author

sduduzog commented Feb 9, 2023

I'll try this again this coming weekend, firstly to reproduce and investigate the culprit causing this. I'll mirror your devDependencies too @blackspike in trying this

@procrates
Copy link

@larbish Issue still exsists on latest version of nuxt 3.2.2. On server I am bypassing RLS with:

import { serverSupabaseServiceRole } from '#supabase/server'

export default defineEventHandler(async (event) => {
  const client = serverSupabaseServiceRole(event)
  const { data: { users }, error } = await client.auth.admin.listUsers()
  return users
})

Which results in [nuxt] [request error] [unhandled] [500] main.createClient is not a function

Using latest nuxt-supabase and nuxt.

@larbish larbish reopened this Feb 20, 2023
@zkschmitz
Copy link

Same here - tried on 3.1.1 as well if that helps!

@sduduzog
Copy link
Author

sduduzog commented Mar 4, 2023

@larbish I think I got it!

so I ripped out the module and used the supabase client directly to try figure out what was the issue but followed how the module was setting it up.

I get this error
image
when transpiling the supabase library, as per the module, but without transpiling it, everything works fine.

Perhaps its time to review this bit of code

// Transpile @supabase/ packages

Also, I'm on nuxt v3.2.3 at the time of finding this

@zefman
Copy link

zefman commented Mar 9, 2023

Yep I'm getting this as well now

@kyng-cytro
Copy link

Is this fixed now? just got the same error.

@kyng-cytro
Copy link

After intensive debugging, I figured out a workaround for this issue. It turns out you need at least one root server route that uses the serverSupabaseClient for it to work, unless you keep getting the main.createClient is not a function error.

import { serverSupabaseClient } from "#supabase/server";
export default eventHandler(async (event) => {
  const client = serverSupabaseClient(event);
  return {
    working: "true",
  };
});

Just add the above code to server/api/index.ts

not sure it'll work for everyone but it's worth a try I guess.

@sduduzog
Copy link
Author

@kyng-cytro This works for me too, I already had a root endpoint and I just had to re-install and enable the module

Copy link
Collaborator

larbish commented Apr 3, 2023

Hey guys, are you still experiencing this issue in v0.3.5 ?

@larbish larbish closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
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

7 participants