Skip to content

fix: settle contended TUS lock waits on abort - #1345

Open
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/tus-lock-abort-settlement
Open

fix: settle contended TUS lock waits on abort#1345
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/tus-lock-abort-settlement

Conversation

@hsusul

@hsusul hsusul commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #1344

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When PostgreSQL-backed TUS lock acquisition is waiting on a contended resource, aborting the acquisition clears both retry timers without resolving either promise. Both branches of the acquisition race can remain pending until the surrounding transaction timeout.

What is the new behavior?

Abort-aware lock waits now settle and remove their listeners on both timeout and abort. The contention backoff reuses that behavior, already-aborted signals are honored, and the outer stop-signal listener is removed when acquisition finishes.

Tests

Added a deterministic regression test that enters the ResourceLocked retry path, aborts after the release request is published, and verifies acquisition settles on the next event-loop turn.

Validated with:

  • Focused PostgreSQL TUS locker tests: 4 passed
  • Full unit suite: 137 files, 1,740 tests passed
  • npm run lint
  • npm run build
  • git diff --check

Additional context

#1115 also touches this file as part of a broader database transaction refactor, but its contended retry wait retains the same abort-time pending-promise behavior.

Signed-off-by: Henry Su <henrysu4707@gmail.com>
@hsusul
hsusul requested a review from a team as a code owner August 23, 2026 16:26
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.

Aborting a contended PostgreSQL TUS lock leaves acquisition pending

1 participant