Skip to content

Endless loop when _error render throws on client side #6973

@dorian-marchal

Description

@dorian-marchal

Bug report

Describe the bug

When using a custom _error page, Next can enter an infinite loop if _error render throws on client side (with a production build).

To Reproduce

Repro here : https://github.com/dorian-marchal/next-repro/tree/repro-6973

In a terminal:

$ git clone -b repro-6973 https://github.com/dorian-marchal/next-repro
Cloning into 'next-repro'...

$ cd next-repro/

$ node -v
v10.14.1

$ npm install

$ npm ls next
next-repro@1.0.0 /tmp/next-repro
└── next@8.0.4

$ npm run build && npm run start
...
> Ready on http://localhost:3000

In your browser:

  • Go to http://localhost:3000/
  • Open your browser devtools
  • Click on "Client side nav"
  • See the app entering an endless loop (stopped after 20 iterations).

Expected behavior

On client side, if _error throws, I expect an "Internal Error" page (this is what happens when _error throw during server side rendering).

I suppose that Next could force a page reload in this case.

System information

  • OS: Ubuntu 18.04
  • Version of Next.js: 8.0.4

Additional context

In our project, this error happens when _error getInitialProps fails to retrieve some dependencies (Error.render tries to access an undefined property).

Metadata

Metadata

Assignees

Labels

good first issueEasy to fix issues, good for newcomers

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions