Skip to content

test: stop the argon2 password tests timing out under load - #210

Merged
aquie00t merged 1 commit into
mainfrom
fix/argon2-test-timeout
Aug 24, 2026
Merged

test: stop the argon2 password tests timing out under load#210
aquie00t merged 1 commit into
mainfrom
fix/argon2-test-timeout

Conversation

@aquie00t

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes three tests that fail whenever the machine running them 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

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 default testTimeout on 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:

(pnpm test:unit & pnpm test:unit & wait)

suite A:  Tests  3 failed | 718 passed (721)
suite B:  Tests  3 failed | 718 passed (721)

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 describe block:

describe("PasswordService", { timeout: 30_000 }, () => {

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 and tsconfig.build.json, so nothing shipped is affected.


Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Chore

Checklist

  • My branch follows the naming convention (feature/, fix/, chore/, docs/)
  • My commits follow Conventional Commits
  • I have tested my changes locally
  • I have not introduced any breaking changes
  • I have updated relevant documentation if needed

🤖 Generated with Claude Code

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>
@aquie00t
aquie00t merged commit eef37fe into main Aug 24, 2026
10 checks passed
@aquie00t
aquie00t deleted the fix/argon2-test-timeout branch August 24, 2026 23:22
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant