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

fix(vue): handle undefined on (fixes #8625) #9011

merged 1 commit into from Jul 10, 2022


Copy link


fixes #8625

refs #8626

Additional context

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added plugin: vue p2-nice-to-have 🍰 Not breaking anything but nice to have (priority) labels Jul 9, 2022
Copy link

netlify bot commented Jul 9, 2022

Deploy Preview for vite-docs-main canceled.

Name Link
🔨 Latest commit 8b705e7
🔍 Latest deploy log

@sapphi-red sapphi-red changed the title fix(vue): handle undefined on hot.accept (fixes #8625) fix(vue): handle undefined on (fixes #8625) Jul 9, 2022
Copy link

So with an undefined mod we still calls .acept to give users a way to react to errors? Do we have special handling for this somewhere? Or we always bail out?

Copy link

bluwy commented Jul 10, 2022

I had also wondered about how errors are reported with, and I found FredKSchott/esm-hmr#3 (though the convo sort-of derailed to client errors instead of build errors). I'm not sure what's the correct way here, but if Vite proceeds with undefined module being an error happened, it may soon become a standard by itself.

Copy link
Member Author

We still call .accept with undefined mod for that reason (I'm not sure if it is useful).
There isn't a special handling nor a comment about this, so it could be a non-intended behavior.

Here, when there is an error at import, moduleMap.set(dep, newMod) won't be called.

try {
const newMod: ModuleNamespace = await import(
/* @vite-ignore */
base +
path.slice(1) +
`?import&t=${timestamp}${query ? `&${query}` : ''}`
moduleMap.set(dep, newMod)
} catch (e) {
warnFailedFetch(e, dep)

So this moduleMap.get(dep) will be undefined.

for (const { deps, fn } of qualifiedCallbacks) {
fn( => moduleMap.get(dep)))

Copy link

I think that maybe an API specific to communicating errors could be better here. But maybe I'm missing some context. We can merge this, and in any case, count it as a temporal guard and discuss this in the next team meeting.

@patak-dev patak-dev merged commit 70af44a into vitejs:main Jul 10, 2022
@sapphi-red sapphi-red deleted the fix/vue-handle-accept-undefined branch July 10, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
p2-nice-to-have 🍰 Not breaking anything but nice to have (priority)
Archived in project

Successfully merging this pull request may close these issues. callback attempts to destructure undefined when changed file contains errors
3 participants