Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(limiter): fix intermittent failures (#2716)
The limiter middleware unit tests are failing due to a race between the storage garbage collector and the unit test itself. The sliding window limiter tracks requests using memory storage. In several of the unit tests, this storage expiry ends up being 4 seconds. The test waits for 4 seconds, then sends a request, expecting it to succeed. However, the unit test occasionally wakes up before the storage GC kicks in. As an effect of the very coarse timer (using seconds as units), the middleware correctly rejects the request, causing the test to fail. Update the sleep to 4.5 seconds. This will not slow down the execution of the test suite, as these tests run in parallel with a separate 9 second long test. I'm not 100% sure this solves the issue, and ideally we'd be able to run tests without time.Sleep.
- Loading branch information