fix(execution): treat an undetermined lease as a fallback, not a denial

Merged
WA
2mo ago
+152-32

Summary

  • The distributed owner lease for code execution is a cross-process fairness check, not a correctness lock. A lease round trip that returned no answer before its deadline was treated as a hard failure and rejected the execution outright, even though the per-process pool and the per-owner active/queued limits already bound the work.
  • Fall back to those local limits when the lease is undetermined. limit_exceeded still denies, since it is an actual answer rather than the absence of one.
  • Renamed that outcome from unavailable to undetermined so a missing answer is not read as a negative one, and dropped its log level to warn.
  • Made the round-trip deadline configurable via IVM_LEASE_REDIS_DEADLINE_MS and raised the default from 200ms to 1000ms. This deadline and the client's commandTimeout are both plain timers, so a value close to normal event-loop latency misreads a scheduling pause (a GC pause, say) as an unreachable dependency.
  • Skip the lease-release round trip when no lease was ever registered.

Type of Change

  • Bug fix

Testing

vitest run lib/execution/isolated-vm.test.ts — 14 passing, including three new cases covering the fallback (no client, evaluation error, deadline exceeded) and one asserting the over-limit path still denies. Each new test was verified to fail against the previous behavior. bun run type-check, bun run lint, and bun run check:audits (39 audits) all 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)