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

Error 500 on page reload (Cannot use 'in' operator to search for 'catch' in undefined) #89

Closed
Ponkhy opened this issue Oct 19, 2022 · 9 comments · Fixed by #109
Closed
Assignees
Labels
bug Something isn't working

Comments

@Ponkhy
Copy link

Ponkhy commented Oct 19, 2022

Version

@nuxtjs/supabase: 0.2.0 and 0.2.1
nuxt: 3.0.0-rc.12 and 3.0.0-rc.11

Steps to reproduce

I haven't quite figured out how to trigger it yet, but I mostly it happens after you stayed logged in for over a hour without doing anything and then refresh the browser window.
After a 2nd refresh it does work normally again.

What is Expected?

Not to run into a error 500

What is actually happening?

Showing a error 500 on page reload

Cannot use 'in' operator to search for 'catch' in undefined
at Module.executeAsync (./node_modules/unctx/dist/index.mjs:93:15)
at ./node_modules/@nuxtjs/supabase/dist/runtime/plugins/supabase.server.mjs:24:49
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.callAsync (./node_modules/unctx/dist/index.mjs:53:16)
at async applyPlugin (./node_modules/nuxt/dist/app/nuxt.mjs:94:23)
at async Module.applyPlugins (./node_modules/nuxt/dist/app/nuxt.mjs:104:5)
at async createNuxtAppServer (./node_modules/nuxt/dist/app/entry.mjs:30:7)
at async default (./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:27:18)
at async Object.renderToString (./node_modules/vue-bundle-renderer/dist/runtime.mjs:172:19)

Does anyone have a idea what could cause it?

I have already reinstalled the node_modules folder and cleared the lock file.

@Ponkhy Ponkhy added the bug Something isn't working label Oct 19, 2022
@Solemensis
Copy link

this was happening to me too, it was caused when there was no logged in user but something still forces to get user info to do something in my page. So find the thing that forces your user to do something (even console.log(user) can count) and make it conditional. so if it is (console.log(user)), make it (if(user)console.log(user))

@Ponkhy
Copy link
Author

Ponkhy commented Oct 20, 2022

Hey,

I've tried that now too, but unfortunately didn't resolve the problem.

@kelyamany
Copy link

kelyamany commented Oct 24, 2022

This happens to me as well, I'm using a simple server middleware to allow incoming api requests, here is a snippet of my code too

import { serverSupabaseUser } from '#supabase/server'

export default defineEventHandler(async (event) => {
  if (!event.req.url.includes('api') || event.req.url.includes('session')) {
    return
  }
  const user = await serverSupabaseUser(event) // the exception is triggered from this call

  if (user?.aud == 'authenticated') {
    return
  }
  throw createError({
    statusCode: 401,
    statusMessage: 'Unauthorized',
    message: 'You have to login to access this path',
  })
})

The only solution I found is to signout and sign in again

Copy link
Collaborator

larbish commented Oct 24, 2022

I'll be glad if someone can create a repository or a stackblitz with a reproduction scenario 🙏

@Ponkhy
Copy link
Author

Ponkhy commented Oct 24, 2022

I'll be glad if someone can create a repository or a stackblitz with a reproduction scenario 🙏

Hi,
I've created a little repo for you, with it I was able to trigger the error whenever I want.
If you have any further questions please let me know!

Repo: https://github.com/Ponkhy/Nuxt-Supabase-Error-500/

@heikopaiko
Copy link

I am getting this, after the session ran out and returning to the still opened browser window/tab.

@Bryanoxx
Copy link

Hello! Just to confirm that I also have this bug, on the previous versions and the current one (v0.2.3) ✅

@Ponkhy
Copy link
Author

Ponkhy commented Nov 15, 2022

Can confirm it's working with v0.2.5.
Thank you very much for the fix! @larbish

@manniL
Copy link
Contributor

manniL commented Dec 3, 2022

@larbish I think you can use navigateTo again, given the underlying issue was fixed in unjs/unctx#43

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

Successfully merging a pull request may close this issue.

7 participants