-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
"Component is missing template or render function" after HMR #610
Comments
This bug can be very annoying when working with multiple nested components and changing them all at once because after that you have to go through each and make sure it renders properly by just hitting save multiple times. |
Bug is still present on Vue 3.0.0-rc.5 |
This is quite weird as I've never ran into this and I can't reproduce it even using the exact dependencies in your repro (via For other people upvoting this issue - could you share your system environment? |
System Info
Steps
In my case, if it diden't happen, shut down terminal and run |
Hi, same problem here with |
System Info
|
@yyx990803, I tried to make the issue more reproducible. I took to docker and tired out multiple versions of the node. After bug reproduced easily for me on any recent version, I tried paying attention to how I edit the file. Turned out, using Vim/Nano does not reproduce the bug: only using VSCode does, even without any extensions enabled. Blaming VSCode is strange because it's just an editor, so I thought that it differs in working with files somehow. And so, I found a stable reproduction case (at least for me). It was added to the original repo as a I don't know who should investigate the issue: it might be Vite's file watching bug, or it might be an undocumented behaviour of VSCode. If the issue is still not reproducible for you, please let me know, I'll try some over OS's and try to pinpoint the issue. |
@yyx990803, I managed to reproduce the bug using the updated repo with the script on the latest macOS. |
Same problem happened in vue@3.0.0-rc.1 & vite@3.0.0-rc.1 and windows7. I found if i restart the terminal the problem can be solved |
The same problem happened |
Could anyone leaving a comment with their environment also specify which editor they use? I still think the issue lies in a way some editors save their files and how the saving is tracked. |
@icehaunter you're correct. I can reproduce the issue on Ubuntu 20.04, vite@1.0.0-rc.4, vue@3.0.0-rc.9 with Visual Studio Code (tried both regular and Insiders version, installed through snap and apt), but it immediately goes away if I switch to any other editor (tried vim, nano, PyCharm and the default Text Editor that comes with Gnome). |
it's work correct if editor changes file, but if editor replace file ( i'm using (Idea) upload on save ) it caches empty file Quickaround fix is set timeout to reload function in serverPluginVue.js
|
Looks like @icehaunter is right. |
or even better to configure awaitWriteFinish to watcher options in [index.ts] Line 64 in f005c67
something like this
|
@Snowing First solution seems to solve the issue, thanks.
You should send a PR. |
Has other guys reslove it via #610 (comment) ? |
The fix could broke when installing a package, just to point it out. |
I can confirm that resolves the issue. It was also happening to me while using vscode but after adding
to I tested with and without the fix alternatively during some periods of my work time, never saw the issue while using the Thanks a lot! Already having fun with vite |
Thanks all guys great catch:) |
Great, this could be the solution to some annoying test-suite timeouts i got in svite when writing files with node fs. Did you test the settings with slow hardware (eg. old 5400rpm hdd under load)? The chosen values for awaitWriteFinish seem a bit low. Could it be possible to expose the watcher setup/config so users can optimize it for their platform/needs? (with sensible defaults ofc) |
Could a release be made? This is a pretty important issue and really annoying. It also happens with WebStorm and I couldn't find any settings affecting how the IDE saves files to get around it. |
This issue still persists for people trying out |
I stand corrected. It seems the fix is merged here - #824. Still, please reopen this issue till a release is made and confirmed that it fixes this issue. |
Is there an ETA when this is going to be released? Currently the issue still exists with the latest released version. |
@jhadenfeldt you might want to try the package |
The easiest temporary fix is to follow these instructions and use the latest vite master locally - it's just a local change that doesn't require any changes to the project you're working on. |
Previous fix introduced a 100ms minimum delay for all HMR updates which is very inefficient.
Describe the bug
When using Vite with Vue 3, regularly a component update will cause the component to vanish from the browser page and the following error will be presented: "Component is missing template or render function". This can be caused by a change as small as adding whitespace to the script block.
I have noticed that the issue is present across all components for me, whether they use object syntax, composition API, or the new
<script setup>
block. I am using TypeScript exclusively, but the root component (App.vue
from the standard init script) also had the same problem despite not using TS.Reproduction
The behavior was demonstrated in vuejs/core#1620 (comment) when I did a reproduction of a different bug - pay attention to the browser console. That recording uses older Vue/Vite, but the problem is reproducible for me on the latest versions.
Here is reproduction repo (it is the same as in the issue above, but I updated dependencies and checked again - error is still present). I tested the issue in Chrome and Firefox.
Steps
npm ci
npm run dev
and open browsercomponents/HelloWorld.vue
multiple times, for example adding a line break after<script>
Update
After some experimenting, I found that the error stems from file saving. VSCode saved files somehow differently to, say, Vim, and seems to save multiple times quickly, even without any plugins enabled.
I managed to boil the reproduction down to a script, which is now present in the reproduction repo. And so, the new steps are:
3. Execute
node ./reproduce_bug.mjs
4. See that the component is not rendered and a warning is printed to browser console
Screenshots
Error:
Valid again:
System Info
vite
version: 1.0.0-rc.3vue
version (fromyarn.lock
orpackage-lock.json
): 3.0.0-rc.4@vue/compiler-sfc
version: "@vue/compiler-core"The text was updated successfully, but these errors were encountered: