Skip to content

fix(bounties): atomic status update in expireOverdue to prevent race condition (#460) - #468

Open
Proxima84-code wants to merge 3 commits into
MergeFi:mainfrom
Proxima84-code:fix/atomic-expire-overdue-460
Open

Proxima84-code wants to merge 3 commits into
MergeFi:mainfrom
Proxima84-code:fix/atomic-expire-overdue-460

Conversation

@Proxima84-code

@Proxima84-code Proxima84-code commented Sep 27, 2026 •

Copy link
Copy Markdown

Summary

Resolves #460 by ensuring that expiring overdue bounties (expireOverdue) is executed as an atomic database operation, eliminating race conditions between concurrent status checks and status transitions. Additionally, synchronizes the branch with current changes from main, resolving merge conflicts and aligning controller signatures, TypeORM query types, and NestJS test module providers.

Changes

  • Atomic Expiration Logic (BountiesService.expireOverdue() overwrites concurrently-advanced bounties to EXPIRED — read-then-save with no status re-check and no assertTransition #460): Implemented atomic status update and query builder execution in BountiesService.expireOverdue to transition overdue bounties (OPEN, FUNDED, CLAIMED) to EXPIRED atomically. Mock and state transitions verified in bounties.service.spec.ts.
  • Idempotency Provider Wiring: Configured getRepositoryToken(IdempotencyKey) and Reflector in bounties.controller.spec.ts to satisfy dependencies required by IdempotencyInterceptor.
  • Caller Context & Pipe Alignments: Updated test assertions in bounties.controller.spec.ts for create, fund, and refund to reflect injected callerUserId and passed undefined as any for absent query parameter validation.
  • Sponsor Authorization Fixtures: Added explicit sponsorId matching callerUserId in mock objects to pass authorization checks in refund tests.
  • Cross-Module Alignments: Aligned poolService.create signature in maintenance-pool.controller.ts, handled optional recipientId typing in maintenance-pool.service.ts, and updated test calls in teams.controller.spec.ts.

Verification

  • npx tsc --noEmit (0 errors)
  • npm test -- src/bounties/ (4/4 test suites passed, 39/39 tests passed)

Closes #460

@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Proxima84-code is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BountiesService.expireOverdue() overwrites concurrently-advanced bounties to EXPIRED — read-then-save with no status re-check and no assertTransition

1 participant