Skip to content

Strapi v5: throws undefined on network errors causing Nitro crash #510

@kong-dev

Description

@kong-dev

When using Strapi v5, the module may throw undefined instead of a valid error object when a request fails (e.g. network/SSL error).

This causes a crash in Nitro during SSR:

Cannot read properties of undefined (reading 'statusText')

Version

@nuxtjs/strapi: 2.1.1
nuxt: 4.4.2

Reproduction Link

https://github.com/kong-dev/reproductions/tree/main/nuxt-modules-strapi-v5-throws-undefined

Steps to reproduce

  1. npx tiged kong-dev/reproductions/nuxt-modules-strapi-v5-throws-undefined reproduction
  2. cd reproduction
  3. pnpm install
  4. pnpm dev
  5. open browser

What is Expected?

The app should build and run without errors.

What is actually happening?

The app crashes.


Root cause

In useStrapiClient, errors are resolved with:

const e = err.data || defaultErrors(err)[version]

However, defaultErrors only defines v3 and v4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions