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: Only empty the .temp directory at most once per run (fix #2254) #2612

Merged
merged 2 commits into from
Nov 1, 2020

Conversation

dtinth
Copy link
Contributor

@dtinth dtinth commented Sep 16, 2020

Summary

To avoid compilation errors caused by removed files.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

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)

To avoid compilation errors caused by removed files
@dtinth dtinth changed the title Only empty the .temp directory at most once per run (fix #2254) fix #2254 by only emptying the .temp directory at most once per run Sep 16, 2020
@dtinth dtinth changed the title fix #2254 by only emptying the .temp directory at most once per run fix: by only emptying the .temp directory at most once per run (fix #2254) Sep 16, 2020
@dtinth dtinth changed the title fix: by only emptying the .temp directory at most once per run (fix #2254) fix: Only empty the .temp directory at most once per run (fix #2254) Sep 16, 2020
Copy link
Collaborator

@billyyyyy3320 billyyyyy3320 left a 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?

@dtinth
Copy link
Contributor Author

dtinth commented Oct 21, 2020

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.

@dtinth
Copy link
Contributor Author

dtinth commented Oct 21, 2020

@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.

Copy link
Collaborator

@billyyyyy3320 billyyyyy3320 left a 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).

@dtinth
Copy link
Contributor Author

dtinth commented Nov 1, 2020

@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.

@billyyyyy3320 billyyyyy3320 merged commit 970b434 into vuejs:master Nov 1, 2020
@dtinth
Copy link
Contributor Author

dtinth commented Nov 1, 2020

Thanks @billyyyyy3320!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants