-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: Only empty the .temp
directory at most once per run (fix #2254)
#2612
Conversation
To avoid compilation errors caused by removed files
.temp
directory at most once per run (fix #2254).temp
directory at most once per run
.temp
directory at most once per run.temp
directory at most once per run (fix #2254)
.temp
directory at most once per run (fix #2254).temp
directory at most once per run (fix #2254)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Sorry for the very late review.
I'll have to check again how we use .temp
. Before that, how would you suggest us to test it? I couldn't reproduce the error. Do you have a repo for reproduce?
Thanks for reviewing! I haven’t dug deep into why it happens, but it seems like a race condition when recompiling. When the directory is emptied, sometimes it causes problem with the file watcher (it stoppped watching files). I will create a minimal reproducable case and update you. |
@billyyyyy3320 Here is a reproduction case. https://codesandbox.io/s/nostalgic-meadow-456zx?file=/README.md I put it on CodeSandbox so that we are reproducing the issue on the same environment. I made sure to use the latest version of VuePress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the commit message b507fae , The code changes was trying to empty temp dir before launching app instead of before reloading app.
However, I found plugin-register-components generates new files whenever app reload. It means there'll be redundant files in temp dir, and they'll keep increasing until the dev server restart.
It'd be great if you could help fix the issue with plugin-register-components. Or please at least leave a comment about this known issue in codebase or github issue (IMO, the original issue you fixed is important than this).
@billyyyyy3320 Yes, this is an expected side effect, but even with that, the dev server no longer crashes. This solution is backed by hours of real world usage. It has been shown that emptying the temp directory was not safe while the server is running. I could not figure out how to make it safe quickly enough so I settled on this solution for now. This solution is not perfect, but in my opinion, I would prefer a bloated temp directory than a server that crashes every 10 minutes of usage. In the original issue, a suggested fix that works was to disable that line entirely. I also worry about temp directory getting too big, so I opted for a compromise. Instead of not emptying the directory at all, at least empty it when starting server. Edit: Just saw your edited comment. Will add a code comment for now. |
Thanks @billyyyyy3320! |
Summary
To avoid compilation errors caused by removed files.
What kind of change does this PR introduce? (check at least one)
If changing the UI of default theme, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes:
To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.
Other information:
Ref: #2254 (comment)