Next.js Discord

Discord Forum

Application error: a client-side exception has occurred while loading....

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
Issue:
I'm using Suspense for data fetching in my Next.js 15 app, and every backend call is inside a try/catch block. However, when a third-party API is unavailable or times out, the entire site crashes, and I see:
“Application error: a client-side exception has occurred while loading.”

What I Don’t Understand:

If the API call is inside a try/catch, how can it still crash the site? Shouldn’t the error just be handled?

I suspect the API request hits a timeout, which is why the page keeps loading for a long time before failing.

The error seems to originate from a Suspense-wrapped component, but I’m not sure if that’s related.

Question:
Why does the app still crash despite the try/catch? Should I wrap the Suspense component in an ErrorBoundary, or is there another way to prevent this?

1 Reply

Dutch
wrap the Suspense component in an ErrorBoundary