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

NuxtErrorBoundary does not work properly when ssr is set to false #24889

Closed
Alireza1996Sh opened this issue Dec 25, 2023 · 1 comment · Fixed by #24896
Closed

NuxtErrorBoundary does not work properly when ssr is set to false #24889

Alireza1996Sh opened this issue Dec 25, 2023 · 1 comment · Fixed by #24896

Comments

@Alireza1996Sh
Copy link

Environment


  • Operating System: Linux
  • Node Version: v18.13.0
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.0
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: telemetry, devtools, ssr, typescript, components, modules, vite, runtimeConfig
  • Runtime Modules: @pinia/nuxt@0.5.1, @nuxt/image@1.0.0
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-m29wph?file=pages%2Findex.vue

Describe the bug

Description

NuxtErrorBoundary component does not work properly under these conditions:

  • nuxt config: ssr: false
  • child component throws error in script setup
<template>
  <div>child component</div>
</template>

<script setup>
throw new Error('just a stupid error for reproduction purpose!');
</script>
  • child component is wrapped between NuxtErrorBoundary component in parent component
<template>
  <div>
    parent component

    <NuxtErrorBoundary>
      <Child />

      <template #error="{error}">
        error handled: {{ error }}
      </template>
    </NuxtErrorBoundary>
  <div>
</template>

Problem

application does not handle component error and just shows error 500 page.

Expectation

NuxtErrorBoundary should render error slot correctly. application should not show error 500 page

Additional context

I checked source code of NuxtErrorBoundary and noticed that there is a wrong condition for setting error

onErrorCaptured((err, target, info) => {
  if (import.meta.client && !nuxtApp.isHydrating) {
    emit('error', err);
    nuxtApp.hooks.callHook('vue:error', err, target, info);
    error.value = err;
    return false;   
  }
});

when ssr is false, there is no need to check nuxtApp.isHydrating.

Logs

No response

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.

2 participants