You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've come across what appears to be a race condition in the vitest test runner. It occurs when using the define configuration option in the vitest config and then referencing a variable defined through it in the import tree of a test file.
I'm not positive of the conditions that reproduce this, but I was able to get a minimal reproduction (linked below). Unfortunately, it can take A LOT of runs (I'm seeing within 30 minutes of repeatedly running the test command) for it to choke, hence why I believe it's race condition.
The best I can tell is that this happens when there is some non-trivial period of time spent importing/resolving/parsing modules in the import path and then referencing a variable in the define from there. The reproduction does this with an artificial delay in a shared file that all the tests import, with some random amount of wait time in it (scoped to a min/max that seems to best reproduce it)
Describe the bug
I've come across what appears to be a race condition in the
vitest
test runner. It occurs when using thedefine
configuration option in the vitest config and then referencing a variable defined through it in the import tree of a test file.I'm not positive of the conditions that reproduce this, but I was able to get a minimal reproduction (linked below). Unfortunately, it can take A LOT of runs (I'm seeing within 30 minutes of repeatedly running the test command) for it to choke, hence why I believe it's race condition.
The best I can tell is that this happens when there is some non-trivial period of time spent importing/resolving/parsing modules in the import path and then referencing a variable in the
define
from there. The reproduction does this with an artificial delay in a shared file that all the tests import, with some random amount of wait time in it (scoped to a min/max that seems to best reproduce it)Reproduction
See: https://github.com/timothympace/vitest-define-bug
There is info in the README, but I'll also copy paste it here:
Steps to reproduce
Run:
Wait for failure. It could take A LOT of runs. I've seen it take up to 30 minutes to reproduce, and it wouldn't shock me if it takes hours even.
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: