question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request missing headers after error-handling through error page

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.4 10:33:52 RootDir: 10:33:53 Nuxt project info: 10:33:53


  • Operating System: Darwin
  • Node Version: v14.19.3
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: yarn@1.22.15
  • Builder: vite
  • User Config: alias, modules, css, build, vite
  • Runtime Modules: @pinia/nuxt@0.1.9, shared-front/nuxt/axios, shared-front/nuxt/cookies, shared-front/nuxt/registry, shared-front/nuxt/domain, shared-front/nuxt/theme, shared-front/nuxt/components, shared-front/nuxt/mq-handler
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-pgghw6

Describe the bug

After handling error, nitro make request to /__nuxt_error, but this request lost all headers, and ErrorPage cannot access them https://github.com/nuxt/framework/blob/bb8942a401cef3d41c39e9d50e6630e766998c1c/packages/nuxt/src/core/runtime/nitro/error.ts#L47

Additional context

Fixed with this code

... $fetch(withQuery('/__nuxt_error', errorObject), {
  headers: event.req.headers,
}) ...

Logs

console.log from minimal-reproduce

app headers {
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  connection: 'close',
  'content-length': '0',
  host: 'localhost:3000',
  origin: 'https://localhost:3000',
  referer: 'https://localhost:3000/',
  'sec-ch-ua': '"Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104"',
  'sec-ch-ua-mobile': '?0',
  'sec-ch-ua-platform': '"macOS"',
  'upgrade-insecure-requests': '1',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
}
[Vue warn]: Unhandled error during execution of setup function 
  at <Error onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
[nitro] [dev] [unhandledRejection] Error: some error
    at setup (/home/projects/github-pgghw6/pages/error.vue:6:7)
    at _sfc_main.setup (/home/projects/github-pgghw6/pages/error.vue:28:23)
    at callWithErrorHandling (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)
    at setupStatefulComponent (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7107:29)
    at setupComponent (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7062:11)
    at renderComponentVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)
    at renderVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:295:22)
    at renderComponentSubTree (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:259:13)
    at renderComponentVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:188:16)
    at renderVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:295:22)
error headers { host: 'localhost' }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Luffyyycommented, Sep 8, 2022

#7174 sounds like my issue (close it and keep this one if it is). I believe this functionality should be optional in some way unless it’s safe to pass headers to the error call 🤔 There are many cases we want to persist a user being logged in despite showing an error page it’s really weird seeing the user not logged for a brief moment.

0reactions
pi0commented, Oct 19, 2022

With last RC.12 we explicitly disable cache for /__nuxt_error as caching was neither easy or good idea. Merging #7340 to land in next release 👍🏼 (you can try on edge channel. please mention if still not passing correctly)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intercept @RequestHeader exception for missing header
I know that I can intercept exception via @ExceptionHandler, but in that case all HTTP 400 requests will be handled, but I want...
Read more >
Guide to Spring Boot REST API Error Handling - Toptal
Implement consumer-friendly support to a Spring Boot REST API by hiding implementation details and delivering easily digestible fields.
Read more >
Custom Error Message Handling for REST API - Baeldung
MissingServletRequestPartException – This exception is thrown when the part of a multipart request is not found.
Read more >
Get Started with Custom Error Handling in Spring Boot (Java)
Learn how to implement custom error handling logic in Spring Boot. You will see two approaches based on the @ControllerAdvice annotation.
Read more >
Handle errors in ASP.NET Core | Microsoft Learn
The exception handling middleware re-executes the request using the ... If the server catches an exception after response headers are sent ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found