-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
For weeks, my application has been plagued by flakey failures due to different forms of the following error:
Error: [birpc] timeout on calling "onAfterSuiteRun"
Where "onAfterSuiteRun" was sometimes "snapshotSaved" or "onTaskUpdate" instead. When this happened, all of my tests would pass, but after completing the tests there would be a long pause followed by the test suite eventually failing due to the above error from somewhere within Vitest itself.
Sometimes, depending on which task timed out, the reporter UI in the terminal would end up in some kind of odd state (like a test never being marked as having completed and passed, despite having done so).
I found #1154, which is the only issue I could find related at all to birpc, but that didn't lead to any insights on how to resolve my problem.
I eventually thought to look in Discord and found this message from May, which described the same issue that I ran into along with something useful -- the error seems related to stubbing Math.random!
Sure enough, I adjusted my code to avoid the Math.random stub and I haven't seen a single one of these errors since!
Reproduction
I have a StackBlitz here that can sometimes show the issue.
Unfortunately, because it's flakey test behavior, I have been unable to consistently reproduce the error (both locally in my app's test suite, before I replaced the Math.random mock, or in StackBlitz). However, after enough times re-running the tests in StackBlitz, I eventually saw the issue a few times
System Info
N/A -- see reproduction in StackBlitzUsed Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.

