fix(execution): release the lease when abort races an undetermined acquisition

Merged
WA
2mo ago
+76-17

Summary

  • The cancellation return for an aborted execution ran before releaseLease was declared, so it exited without releasing the distributed owner lease.
  • An undetermined acquisition can still be registered by Redis after the deadline abandons the local wait. Aborting in that window left the member counted against the owner for the whole TTL, denying later executions that had capacity — the same failure the fallback change set out to remove, on the one exit path that missed it.
  • Declared the release before the early returns so every exit path that can leave a registration behind reaches it, and call it on the cancellation path.
  • The over-limit return still skips the release deliberately: the script answers that before its ZADD, so nothing was ever registered. Noted inline so it is not "corrected" later.

Type of Change

  • Bug fix

Testing

vitest run lib/execution/isolated-vm.test.ts — 16 passing, including a new case asserting that an abort racing an undetermined acquisition still issues the release. Verified it fails against the previous behavior while the existing over-limit abort case keeps passing. bun run type-check, bun run lint, and bun run check:audits (39 audits) pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)