Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): pass and format vite-node build errors #6683

Merged
pi0 merged 13 commits intomainfrom
fix/vite-node-h3-error-passdown
Sep 3, 2022
Merged

fix(nuxt): pass and format vite-node build errors #6683
pi0 merged 13 commits intomainfrom
fix/vite-node-h3-error-passdown

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented Aug 16, 2022

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

To pass down the nested h3 app's error to be handled by the main one. nodeHandler comes with its own error handling (https://github.com/unjs/h3/blob/b95ab25575e1a6c022ff40cfd731d27cb735f621/src/app.ts#L57), changed to handler so it let the error flow down.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 16, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit 9cfee0c
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/631323b82937a20008ddc3e3

@pi0
Copy link
Copy Markdown
Member

pi0 commented Aug 16, 2022

Thanks for PR @antfu. Please use description for next PRs even if we internally discussed 🙏🏼

@antfu
Copy link
Copy Markdown
Member Author

antfu commented Aug 16, 2022

Added, thanks!

@pi0 pi0 marked this pull request as draft August 16, 2022 18:32
@pi0
Copy link
Copy Markdown
Member

pi0 commented Aug 16, 2022

Checking more locally, it seems passing main handler is not enough. Vite node (client) throws nice object with nice trace info (id, plugin, message, name, stack, loc, pluginCode, frame). Passing it up to the dev server handler, won't help. But we could pass it down to the vite-node fetch client. There I tried to restore main error object from HTTP response and throw it in fetchModule of viteNodeRunner. But it will be only handled when we call render...

What happens is: Browser request => Nitro server => SSR => Vite Node Client (Runner) => Fetch A problematic module => Gets error object.

@pi0 pi0 changed the title fix(vite-node): pass down h3 errors fix(vite-node): show error page and stacktrace Aug 16, 2022
@pi0
Copy link
Copy Markdown
Member

pi0 commented Aug 16, 2022

BTW comparing to legacy bundler, we were never handling build errors from server side but using an empty module. They were being then handled on client-side.

I've just pushed 808fd5b to show how similar effect works.

image

@pi0 pi0 changed the title fix(vite-node): show error page and stacktrace fix(vite-node): show server build errors Aug 16, 2022
Comment thread packages/vite/src/vite-node.ts Outdated
@pi0 pi0 mentioned this pull request Sep 1, 2022
@pi0
Copy link
Copy Markdown
Member

pi0 commented Sep 3, 2022

I had been testing giving error data for few cases. There is really no standard for errors coming from vite, rollup plugins and parsers such as babel used for sfc. I've made a temporary normalizer on best efforts and compatible with default error template but we should make something more standard for normalization later.

Script:

image

Template:

image

Style:

image

@pi0 pi0 changed the title fix(vite-node): show server build errors fix(nuxt): pass and format vite-node build errors Sep 3, 2022
@pi0 pi0 marked this pull request as ready for review September 3, 2022 09:40
@pi0 pi0 merged commit 537338f into main Sep 3, 2022
@pi0 pi0 deleted the fix/vite-node-h3-error-passdown branch September 3, 2022 10:02
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants