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(config): add random number to temp transpiled file #12150

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

Akryum
Copy link
Contributor

@Akryum Akryum commented Feb 22, 2023

Description

If two instances of vite server or builder starts simultaneously (within the same millisecond), they will attempt to create the same temporary transpiled file for the configuration. This PR adds a random number to the file name to reduce the chance of them using the same file name to almost zero.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@dominikg
Copy link
Contributor

Note: changing the filename pattern might bust .gitignore templates.

the one we use in create-svelte would match both the old and new version, but others might have used more strict patterns and those would no longer work.

Would it work to do an exists check and then just add one to the timestamp until it doesn't?

Copy link
Contributor Author

Akryum commented Feb 22, 2023

Maybe we can remove the -?

@bluwy
Copy link
Member

bluwy commented Feb 25, 2023

I think I'm fine with this for now. Personally if we're already going this length, I'd call getHash and construct a file name, but that isn't really a "timestamp" and we can't change it drastically without risking the gitignore issue (though I don't think that's part of semver).

So for me I think this PR is good enough 👍

@Akryum Akryum marked this pull request as ready for review February 26, 2023 15:41
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this now and in Vite 5, I think we should start using a _temp_{hash} as we do in deps prebundling folders.

@patak-dev patak-dev merged commit 2b2ba61 into vitejs:main Mar 21, 2023
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.

4 participants