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

No longer sending real errors to _error.js on production builds. #1814

Closed
gcpantazis opened this issue Apr 27, 2017 · 6 comments
Closed

No longer sending real errors to _error.js on production builds. #1814

gcpantazis opened this issue Apr 27, 2017 · 6 comments

Comments

@gcpantazis
Copy link
Contributor

(Copying from #1800 since this is a new issue as a result of that cc/ @arunoda)

#1800 introduced a "fake error" object that's sent to the _error view on production. This creates a feature divergence on dev vs. production, and removed the possibility for tracking errors in getInitialProps.

My use case is that I want to send that error message to our logs, and the _error.js page is the best single place I see to capture errors that break next on both the client and server. i.e.:

export default class ErrorPage extends React.Component {
    static getInitialProps({res, jsonPageRes, err}) {
        if (err) {
            track.metric('render_error');
            // Utility method that serializes JS errors on client and server, sends them to logs
            track.error(err);
        }

        return {}
    }

    render() {
        return (
            <div>...</div>
        )
    }
}

If we're not consistently sending the error object to the error page, do we have a better way to grab and track them?

@arunoda
Copy link
Contributor

arunoda commented Apr 27, 2017

Answered here: #1800 (comment)

@arunoda arunoda closed this as completed Apr 27, 2017
@gcpantazis
Copy link
Contributor Author

Okay, a few questions / points:

  1. These aren't necessarily just server errors, since the apps are universally rendered.
  2. Since this was removed, is there any one place in the application to predictably get all errors from next? Ideally it'd be the same server and client. I've gone through the source and it isn't really clear how errors are supposed to be handled.

@arunoda arunoda reopened this Apr 27, 2017
gcpantazis added a commit to gcpantazis/next.js that referenced this issue Jun 8, 2017
At some point we introduced a split in how we pass errors around in
dev versus prod, and instead of passing the original error object
we began to modify it in production. We also ran an additional
`loadGetInitialProps()`, which caused anything in `_error`'s initial
props method to be loaded twice client-side (first with the previous
path, then with the new path, but both with the same error).

It's unclear to me why this was necessary in the first place, so I've
returned to passing the same `error` object to both the dev and prod
error views. cc/ @arunoda

This resolves vercel#1814 by passing the actual error to the production
`_error` page.

Resolves vercel#1814
gcpantazis added a commit to gcpantazis/next.js that referenced this issue Jun 8, 2017
At some point we introduced a split in how we pass errors around in
dev versus prod, and instead of passing the original error object
we began to modify it in production. We also ran an additional
`loadGetInitialProps()`, which caused anything in `_error`'s initial
props method to be loaded twice client-side (first with the previous
path, then with the new path, but both with the same error).

It's unclear to me why this was necessary in the first place, so I've
returned to passing the same `error` object to both the dev and prod
error views. cc/ @arunoda

This resolves vercel#1814 by passing the actual error to the production
`_error` page.

Resolves vercel#1814
gcpantazis added a commit to gcpantazis/next.js that referenced this issue Jun 11, 2017
At some point we introduced a split in how we pass errors around in
dev versus prod, and instead of passing the original error object
we began to modify it in production. We also ran an additional
`loadGetInitialProps()`, which caused anything in `_error`'s initial
props method to be loaded twice client-side (first with the previous
path, then with the new path, but both with the same error).

It's unclear to me why this was necessary in the first place, so I've
returned to passing the same `error` object to both the dev and prod
error views. cc/ @arunoda

This resolves vercel#1814 by passing the actual error to the production
`_error` page.

Resolves vercel#1814
@sethsamuel
Copy link

This is causing some serious problems for us, since Googlebot is triggering a mysterious client-side error when trying to render our pages, and we have not way of debugging it.

@gcpantazis
Copy link
Contributor Author

Just wanted to bump this up; I'm still relying on a fork to get this functionality in. I'm guessing there isn't a better prescribed way to track errors in production yet since the serializeErrors method in server/render is still gated on dev.

I'm happy to send in a PR if we can agree on the right way to proceed; a next config option to send along the errors in production, perhaps?

cc/ @sergiodxa @arunoda @timneutkens

@gcpantazis
Copy link
Contributor Author

This was fixed as of 4.1.4, closing

@timneutkens
Copy link
Member

Awesome @gcpantazis

@lock lock bot locked as resolved and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants