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

clean command not detecting versions properly #438

Closed
philippevezina opened this issue Mar 5, 2024 · 5 comments
Closed

clean command not detecting versions properly #438

philippevezina opened this issue Mar 5, 2024 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@philippevezina
Copy link

Description 📖

vite_ruby uses the mtime as a reference to detect different versions of the app: https://github.com/ElMassimo/vite_ruby/blob/main/vite_ruby/lib/vite_ruby/commands.rb#L148 That being said, a single Vite build can generate files with more than one mtime. For example, vite-plugin-rails uses rollup-plugin-gzip at the end of the build which will write many files with different mtimes.

This causes files to delete unexpectedly when running bin/vite clean. It's possible this bug is hard to reproduce with a small project as all written files may end up having the same mtime.

Reproduction 🐞

Vite Ruby Info
  • Run bin/rake vite:build on a big project with no currently built assets.
  • Run bin/rake vite:clean[1,0]

Result: files will be deleted while there is only a single version of the built assets.

@philippevezina philippevezina added the bug: pending triage Something doesn't seem to be working, but hasn't been verified label Mar 5, 2024
@ElMassimo ElMassimo added bug Something isn't working help wanted Extra attention is needed and removed bug: pending triage Something doesn't seem to be working, but hasn't been verified labels Mar 26, 2024
@ElMassimo
Copy link
Owner

Hi Philippe, thanks for reporting!

Fixing this will likely require grouping files by modified time using a certain range (maybe 5 minutes is a reasonable default).

@benlangfeld
Copy link

This is a duplicate of #404, right?

benlangfeld added a commit to benlangfeld/vite_ruby that referenced this issue Jul 4, 2024
This was broken in ElMassimo@8a581c1 with no explanation of why it was being removed.
@benlangfeld
Copy link

Fix proposed in #477 which mirrors the behaviour of vite_ruby before a recent tangentially related bugfix, as well as Webpacker.

@philippevezina
Copy link
Author

Fix proposed in #477 which mirrors the behaviour of vite_ruby before a recent tangentially related bugfix, as well as Webpacker.

This PR won't fix the issue described here. The issue still remains that Vite Ruby relies on common mtimes on files to determine the set of files belonging to a certain version. That said, when trying to keep 2 versions of the assets, the returned files may all belong to only a single build rather than 2 because the mtime could be 1 second off for some files.

@benlangfeld
Copy link

Fix proposed in #477 which mirrors the behaviour of vite_ruby before a recent tangentially related bugfix, as well as Webpacker.

This PR won't fix the issue described here. The issue still remains that Vite Ruby relies on common mtimes on files to determine the set of files belonging to a certain version. That said, when trying to keep 2 versions of the assets, the returned files may all belong to only a single build rather than 2 because the mtime could be 1 second off for some files.

Ok, but it will fix guaranteeing you retain at least the most recent version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants