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

import.meta.hot.accept callback attempts to destructure undefined when changed file contains errors #8625

Closed
7 tasks done
ascott18 opened this issue Jun 16, 2022 · 0 comments · Fixed by #9011
Closed
7 tasks done
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@ascott18
Copy link

ascott18 commented Jun 16, 2022

Describe the bug

  • Start up a Vite + Vue3 app
  • Open the browser dev tools and observe the console
  • Introduce a syntax error into a SFC. For example, change import to importasdf in App.vue
  • Observe two expected errors
    • GET ... ERR_ABORTED 404
    • [hmr] Failed to reload /src/App.vue. ...
  • Observe an additional, unexpected error due to hot.accept trying to destructure undefined. See logs below.

Either

acceptDeps([ownerPath], ([mod]) => deps && deps(mod))
needs to not call deps if mod is undefined, or
`import.meta.hot.accept(({ default: updated, _rerender_only }) => {`,
needs to elegantly handle undefined.

Reproduction

https://vite.new/vue-ts

System Info

(--system omitted - running within Stackblitz)

  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^2.3.3 => 2.3.3 
    vite: ^2.9.12 => 2.9.12

Used Package Manager

npm

Logs

Uncaught (in promise) TypeError: Cannot destructure property 'default' of 'undefined' as it is undefined.
    at App.vue:45:36
    at client:519:60
    at client:461:13
    at client:350:60
    at Array.forEach (<anonymous>)
    at queueUpdate (client:350:38)

Validations

@ascott18 ascott18 changed the title import.meta.hot.accept callback is invoked with undefined when changed file contains errors import.meta.hot.accept callback attempts to destructure undefined when changed file contains errors Jun 16, 2022
@ascott18 ascott18 changed the title import.meta.hot.accept callback attempts to destructure undefined when changed file contains errors import.meta.hot.accept callback attempts to destructure undefined when changed file contains errors Jun 16, 2022
@sapphi-red sapphi-red added plugin: vue p2-nice-to-have Not breaking anything but nice to have (priority) and removed pending triage labels Jun 17, 2022
sapphi-red added a commit to sapphi-red/vite that referenced this issue Jul 9, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants