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

fix(vite): include id and stack in vite-node fallback error handler - #7575

Merged
pi0 merged 6 commits into
mainfrom
fix/error-fallback
Sep 16, 2022
Merged

fix(vite): include id and stack in vite-node fallback error handler#7575
pi0 merged 6 commits into
mainfrom
fix/error-fallback

Conversation

@danielroe

@danielroedanielroe commented Sep 15, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

ref nuxt/nuxt#14909

❓ 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

This adds more info in the event of minimal error data. In the linked issue, error data is:

consterrorData={code: "ERR_MODULE_NOT_FOUND",}

That's enough to thwart our formatter.

CleanShot 2022-09-15 at 23 09 56@2x

This PR adds stack + reason fallbacks, transforming it to:

CleanShot 2022-09-15 at 23 09 19@2x

Admittedly probably the stack isn't helpful in this case, but at least the error message tells us the module that couldn't be fetched. Alternatively, maybe we could directly throw the error if we only have a code in errorData?

📝 Checklist

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

@danielroedanielroe added dx vite 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Sep 15, 2022
@danielroe
danielroe requested a review from pi0September 15, 2022 22:12
@danielroedanielroe self-assigned this Sep 15, 2022
@netlify

netlifyBot commented Sep 15, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitc8bf713
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/6324bc24890e120008731618

Comment threadpackages/vite/src/runtime/vite-node.mjs Outdated
Comment threadpackages/vite/src/runtime/vite-node.mjs Outdated
@danielroedanielroe changed the title fix(vite): provide fallback stack + reasonfix(vite): provide fallback reasonSep 16, 2022
@pi0

pi0 commented Sep 16, 2022

Copy link
Copy Markdown
Member

I've made #7589 for a better normalization approach. I think we can change this PR to make fatal errors (unhandled while normalizing) to include module id in the message. But reason is internal preserving it will be confusing.

@danielroe

Copy link
Copy Markdown
MemberAuthor

Sure 👍 Also happy to close this and we can do it all in your linked PR.

@pi0

pi0 commented Sep 16, 2022

Copy link
Copy Markdown
Member

I've double-checked now. Unless formatViteError fails (which is solved with other PR), we show 500 error (network error actually) with path to module id. That should only happen in rare cases of internal error. we could still show moduleId in fallback

@pi0pi0 closed this Sep 16, 2022
@pi0
pi0 deleted the fix/error-fallback branch September 16, 2022 17:45
@pi0
pi0 restored the fix/error-fallback branch September 16, 2022 17:46
@pi0pi0 reopened this Sep 16, 2022
@pi0

pi0 commented Sep 16, 2022

Copy link
Copy Markdown
Member

Improved fallback including id:

(note: this is not real! I had to make an intentional bug to the format error to produce above. just in case we missed something yet for normalization)

image

image

@pi0pi0 changed the title fix(vite): provide fallback reasonfix(vite): include module id in vite-node fallback errorsSep 16, 2022
@pi0pi0 changed the title fix(vite): include module id in vite-node fallback errorsfix(vite): include id and stack in vite-node fallback error handlerSep 16, 2022
@pi0
pi0 merged commit 5bc6544 into mainSep 16, 2022
@pi0
pi0 deleted the fix/error-fallback branch September 16, 2022 18:12
@pi0pi0 mentioned this pull request Sep 20, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xdx🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressingvite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@danielroe@pi0