Skip to content

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

@ascott18

Description

@ascott18

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions