Skip to content

Alarms held open for minutes: PiHarness waits inside the alarm #87

Open

Description

@MiguelsPizza

PiHarness does not use Pi's in-memory timers to wake the object. It pushes one lifecycle job per session with work, refreshes it every 30 seconds as a heartbeat, and waits on Pi inside the alarm invocation for up to 10 minutes (WAIT_BUDGET_MS), registering that wait with lifecycle.trackAlarmWork. Pi waits further away than 60 seconds (SLEEP_THRESHOLD_MS) are handed back to the alarm. The constants assume workerd's 15-minute alarm wall-time limit (packages/agents/src/harness/pi/harness.ts).

In do-runtime an alarm handler can be held open for minutes for the first time. Questions to answer with tests before anything depends on it:

  • Does alarm delivery have a wall-time limit, and should it mirror workerd's 15 minutes so the harness's budget means the same thing here?
  • Does a held alarm keep the host's activity lease, and so stop idle recycling, for its whole duration? For a host that recycles idle runtimes that is the intended behavior while Pi has work, but it should be explicit and tested.
  • When the worker dies while an alarm is held, is the job redelivered exactly once, with the retry ladder alarm-recovery already covers?
  • Does trackAlarmWork find the alarm's dispatch through do-runtime's async context the way it does on workerd (job-driver.ts reads it from an AsyncLocalStorage)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions