Skip to content

fix(pi): resume a sleep that falls due while other work runs - #373

Merged
eersnington merged 1 commit into
mainfrom
pi-wake-while-busy
Nov 2, 2026
Merged

eersnington merged 1 commit into
mainfrom
pi-wake-while-busy

Conversation

@eersnington

Copy link
Copy Markdown
Member

Fixes #372

With onWake, Pi Durable keeps no timer for sleeps. wakeActor() in packages/pi/src/runtime.ts returned on active and ignored at, so a sleep that fell due while other work ran resumed only at the next change to the wake value. A retry due in 2 s did not run within 25 s. This is a regression from #367.

Wake value Before After
{ active: true, at } Stays awake, at ignored Stays awake, in-process timer for at
{ active: false, at } Writes c.schedule.at, then lets the actor sleep Same
Schedule write failed Timer for at, stays awake Same timer
  • The actor cannot sleep while work is active, so this case needs no c.schedule write.
  • The active case and the failed-schedule case share one timer. It is cleared when at changes.
  • The delay is capped at 2 ** 31 - 1 ms. setTimeout fires at once past that limit, so a far-off sleep would spin. An early firing is safe: Pi runs a sleep only once its time has passed, and the wake re-arms.

@railway-app

railway-app Bot commented Nov 2, 2026

Copy link
Copy Markdown

This PR was not deployed automatically as @eersnington does not have access to the Railway project.

In order to get automatic PR deploys, please add @eersnington to your workspace on Railway.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

📟 Pip-Boy · e1c63e5

📦 Packages · fresh npm install resolve, no lockfile · this PR vs base

No notable install size, dependency, or entrypoint changes across 10 packages.

All 10 packages · linux-x64-gnu
package (linux-x64-gnu) @latest base this PR Δ vs base packages
@rivet-dev/pi 244.6 MB 235.5 MB 235.5 MB +932 B (+0.0%) 216 (0)
@rivet-dev/sandbox-adapter 113.8 KB 113.8 KB 113.8 KB 0 1 (0)
@sandbox-agent/cli-shared 27.2 KB 27.2 KB 27.2 KB 0 1 (0)
@sandbox-agent/persist-indexeddb 12.4 KB 12.4 KB 12.4 KB 0 1 (0)
@sandbox-agent/persist-postgres 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/persist-rivet 12.2 KB 12.2 KB 12.2 KB 0 1 (0)
@sandbox-agent/persist-sqlite 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/react 41.5 MB 41.8 MB 41.8 MB 0 15 (0)
acp-http-client 6.7 MB 6.7 MB 6.7 MB 0 3 (0)
sandbox-agent 30.9 MB 30.9 MB 30.9 MB 0 8 (0)

🧹 Rust dependencies

Skipped: this PR doesn't change any Rust code or dependencies.

🦀 Binaries

Skipped: this PR doesn't change any Rust code.

⏱ Timing

job wall time slowest step
changes 19s checkout · 14s
zizmor 22s checkout · 9s
footprint 4m14s Run pnpm --dir sandbox-agent install --frozen-lockfile · 1m33s
⏭ hygiene — skipped
⏭ native · ${{ matrix.platform }} — skipped
⏭ self-test — skipped
report 22s checkout · 11s
🔭 Full CI trace for this commit

One OpenTelemetry trace of CI and Pip-Boy for e1c63e5: every job and step, with the sizes above attached. Run after CI finishes.

pnpm install --frozen-lockfile --filter 'pipboy...'
pnpm --filter pipboy pipboy trace --sha e1c63e52f5608b5eee56acfd99ec68993d62b6c7

Add --otlp <url> to send it to any OTLP/HTTP collector.

Agent instruction: From a rivet-dev/agents checkout, run the commands above, then read the trace file the last command prints. List the slowest jobs and steps and explain where CI time went.

@eersnington
eersnington merged commit ba5ec0c into main Nov 2, 2026
10 checks passed
@eersnington
eersnington deleted the pi-wake-while-busy branch November 2, 2026 19:15
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.

pi(): a Pi Durable sleep that falls due while other work is active resumes late

1 participant