test: stop the argon2 password tests timing out under load - #210
Merged
Conversation
Three cases in password.service.test.ts fail whenever the machine is busy: × should produce different hashes for the same input (salt) 5068ms × should return true when plain password matches hash 5084ms × should return false when plain password does not match 5147ms Each hashes twice, and argon2 is deliberately CPU-hard, so two hashes exceed the suite's 5s default timeout on a loaded runner. Reproducible on demand by running two unit suites concurrently: 3 failures, every time, in both. The cost is the point of the algorithm, so the timeout moves rather than the work - lowering the argon2 parameters would test a configuration production never uses. Scoped to this describe block so 5s stays the default everywhere else, where it is a useful guard on genuinely fast unit tests. After the change the same concurrent run passes 708/708 in both suites. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes three tests that fail whenever the machine running them is busy.
All three are in
tests/unit/infrastructure/security/password.service.test.ts, and all three hash twice. argon2 is deliberately CPU-hard, so two hashes cross the suite's 5 s defaulttestTimeouton a loaded runner. The one test in that file that hashes only once never fails.It is reproducible on demand
I hit this twice as an intermittent failure while working on the article branches, then pinned it down by running two unit suites concurrently:
The same three every time, in both suites. On a shared CI runner this is a matter of when, not if.
The fix
The timeout moves, not the work — scoped to that
describeblock:Lowering the argon2 parameters would have made the tests fast, but it would test a configuration production never uses, which is worth less than the seconds it saves. 5 s stays the default everywhere else, where it is a useful guard on genuinely fast unit tests.
After the change, the same concurrent run passes 708/708 in both suites.
Test-only change:
tests/is outside both the eslint glob andtsconfig.build.json, so nothing shipped is affected.Type of Change
Checklist
feature/,fix/,chore/,docs/)🤖 Generated with Claude Code