Describe the bug
Routes not defined in the site result in an http 502 error (bad gateway). It is assumed this something to do with how Next.js is configured. This has caused issues with google page ranking as pages which have moved or no longer exist no return as an http 502 instead of an http 404.
To Reproduce
Steps to reproduce the behavior:
- go to https://www.thatconference.com/wi/privacy-policy
- see that the site returns an http 502 error
Expected behavior
If the route or page requested is unknown the site the site should return an http 404 error.
Device(s)/Browser(s) this is occurring on
Additional context
- This issue may not occur running locally.
- Unable to reproduce locally using
vc dev or npm run dev
- The error shown by
CloudFlare is the same error displayed when running directly against vercel.
It seems we're not getting the expected information when running at vercel. After placing some console logs in the _error.js file it revealed:
$$$$$ do we have a response object? true
$$$$$ Status code 200
$$$$$ asPath is: /wi/privacy-policy3
$$$$$ err is: undefined
$$$$$ we have a conditions which shouldnt happen
So running in vercel event though the path doesn't exist the response is a 200 with no error object. This was causing the error below which is in sentry.js trying to read a value not there. A side affect of this bigger issue running at vercel.
The site returns an http 404 response, but we are still going to the error page which doesn't handle things correctly and displays an error.
Stack trace of error at vercel
[GET] /wi/privacy-policy 08:25:38:89
server/lib/utils.js:5:91)
at async Function.appGetInitialProps (/var/task/.next/serverless/pages/_error.js:1836:21)
at async Function.getInitialProps (/var/task/.next/serverless/pages/_error.js:488:20)
2020-11-04T14:25:38.952Z 201b5e55-b5ad-453d-8d33-9d5da6a50c53 ERROR Failed call /_error subroutine, continuing to crash function: TypeError: Cannot read property 'sid' of undefined
at /var/task/.next/serverless/pages/_error.js:2945:27
at Hub.configureScope (/var/task/node_modules/@sentry/hub/dist/hub.js:268:13)
at callOnHub (/var/task/node_modules/@sentry/minimal/dist/index.js:18:28)
at Object.configureScope (/var/task/node_modules/@sentry/minimal/dist/index.js:81:5)
at captureException (/var/task/.next/serverless/pages/_error.js:2913:12)
at Function.module.exports.Y0NT.MyError.getInitialProps (/var/task/.next/serverless/pages/_error.js:4615:83)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async loadGetInitialProps (/var/task/node_modules/next/dist/next-server/lib/utils.js:5:91)
at async Function.appGetInitialProps (/var/task/.next/serverless/pages/_error.js:1836:21)
at async Function.getInitialProps (/var/task/.next/serverless/pages/_error.js:488:20)
2020-11-04T14:25:38.952Z 201b5e55-b5ad-453d-8d33-9d5da6a50c53 ERROR TypeError: Cannot read property 'sid' of undefined
at /var/task/.next/serverless/pages/_error.js:2945:27
at Hub.configureScope (/var/task/node_modules/@sentry/hub/dist/hub.js:268:13)
at callOnHub (/var/task/node_modules/@sentry/minimal/dist/index.js:18:28)
at Object.configureScope (/var/task/node_modules/@sentry/minimal/dist/index.js:81:5)
at captureException (/var/task/.next/serverless/pages/_error.js:2913:12)
at Function.module.exports.Y0NT.MyError.getInitialProps (/var/task/.next/serverless/pages/_error.js:4635:79)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async loadGetInitialProps (/var/task/node_modules/next/dist/next-server/lib/utils.js:5:91)
at async Function.appGetInitialProps (/var/task/.next/serverless/pages/_error.js:1836:21)
at async Function.getInitialProps (/var/task/.next/serverless/pages/_error.js:488:20)
2020-11-04T14:25:38.953Z 201b5e55-b5ad-453d-8d33-9d5da6a50c53 ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'sid' of undefined","reason":{"errorType":"TypeError","errorMessage":"Cannot read property 'sid' of undefined","stack":["TypeError: Cannot read property 'sid' of undefined"," at /var/task/.next/serverless/pages/_error.js:2945:27"," at Hub.configureScope (/var/task/node_modules/@sentry/hub/dist/hub.js:268:13)"," at callOnHub (/var/task/node_modules/@sentry/minimal/dist/index.js:18:28)"," at Object.configureScope (/var/task/node_modules/@sentry/minimal/dist/index.js:81:5)"," at captureException (/var/task/.next/serverless/pages/_error.js:2913:12)"," at Function.module.exports.Y0NT.MyError.getInitialProps (/var/task/.next/serverless/pages/_error.js:4635:79)"," at processTicksAndRejections (internal/process/task_queues.js:97:5)"," at async loadGetInitialProps (/var/task/node_modules/next/dist/next-server/lib/utils.js:5:91)"," at async Function.appGetInitialProps (/var/task/.next/serverless/pages/_error.js:1836:21)"," at async Function.getInitialProps (/var/task/.next/serverless/pages/_error.js:488:20)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'sid' of undefined"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:327:22)"," at process.EventEmitter.emit (domain.js:483:12)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
Unknown application error occurred
Describe the bug
Routes not defined in the site result in an http 502 error (bad gateway). It is assumed this something to do with how Next.js is configured. This has caused issues with google page ranking as pages which have moved or no longer exist no return as an http 502 instead of an http 404.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
If the route or page requested is unknown the site the site should return an http 404 error.
Device(s)/Browser(s) this is occurring on
Additional context
vc devornpm run devCloudFlareis the same error displayed when running directly against vercel.It seems we're not getting the expected information when running at vercel. After placing some console logs in the _error.js file it revealed:
So running in vercel event though the path doesn't exist the response is a 200 with no error object. This was causing the error below which is in
sentry.jstrying to read a value not there. A side affect of this bigger issue running at vercel.The site returns an http 404 response, but we are still going to the error page which doesn't handle things correctly and displays an error.
Stack trace of error at vercel