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

Built in error page doesn't show reliably #27445

Closed
imdavidmin opened this issue Jul 23, 2021 · 2 comments
Closed

Built in error page doesn't show reliably #27445

imdavidmin opened this issue Jul 23, 2021 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@imdavidmin
Copy link

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

15.2.1

What browser are you using?

Edge Chromium

What operating system are you using?

Windows

How are you deploying your application?

next dev

Describe the Bug

The error page doesn't show when there is a runtime error.

The issue I had was importing gsap when it needed the next-transpile-modules package as currently Next.js is not supporting ES6 modules. When navigating to the page, the next dev server logs the following:

event - build page: /Admin
wait  - compiling...
event - compiled successfully
event - build page: /next/dist/pages/_error
wait  - compiling...
event - compiled successfully

So the page builds ok, but immediately followed by the default error page. However, in browser, the request simply hangs and the page doesn't load. I don't see any error being displayed back to me or in console.

Expected Behavior

See error.

The problem can be worked around by creating a custom error page _error. Using documentation code:

function Error({ statusCode }) {
    return (
        <p>
            {statusCode
                ? `An error ${statusCode} occurred on server`
                : 'An error occurred on client'}
        </p>
    )
}

Error.getInitialProps = ({ res, err }) => {
    const statusCode = res ? res.statusCode : err ? err.statusCode : 404
    return { statusCode }
}

export default Error

To Reproduce

import gsap from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';

without the following in next.config.js

const withTM = require('next-transpile-modules')(['gsap']); 

module.exports = withTM({ });
@imdavidmin imdavidmin added the bug Issue was opened via the bug report template. label Jul 23, 2021
@balazsorban44
Copy link
Member

I could not reproduce this anymore. The page loads nicely, showing the error:

image

The underlying issue might have been fixed at a later point, please upgrade to next@latest

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants