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 (from template) rendered instead of 404 (from createErrror) #14695

Closed
some-user123 opened this issue Aug 25, 2022 · 3 comments · Fixed by nuxt/framework#7290
Closed

Comments

@some-user123
Copy link

some-user123 commented Aug 25, 2022

Environment


  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-8gwl3q?file=app.vue

Describe the bug

If useAsyncData returns an error, throw createError(...) doesn't work properly. Template errors are being caused and error 500 is rendered.

Actual:

  • Error 500 (Cannot read properties of undefined (reading 'attr')) is rendered if template uses state.attr
  • Error 500 (Cannot read properties of undefined (reading 'something')) is rendered if template uses data.something
  • Error 404 is rendered if template doesn't access state.attr nor data.something

Expected:

  • Error 404 should be rendered in all cases

Additional context

#13788

Logs

No response

@Aareksio
Copy link
Contributor

Aareksio commented Aug 25, 2022

While easily mitigated by v-if="data" and similar conditions, this is a major DX downgrade from Nuxt 2 experience where we could throw error in asyncData and not have to worry about template or computed accessing properties of undefined.

@danielroe
Copy link
Member

There is an upstream issue that breaks Nuxt after a rendering error: vuejs/core#6110.

The fix here is relatively simple but I'll need to defer it until the upstream bug is fixed in Vue core (or until we can workaround it again in Nuxt).

@misaon
Copy link
Contributor

misaon commented Sep 5, 2022

@danielroe Is there any workaround to get around the error at this point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants