Skip to content

fix(runtime): complete a context call when its result settles - #2073

Merged
eersnington merged 1 commit into
mainfrom
fix/context-call-completion
Oct 21, 2026
Merged

eersnington merged 1 commit into
mainfrom
fix/context-call-completion

Conversation

@eersnington

Copy link
Copy Markdown
Member

Fixes #1991.

A context call that left a setInterval or a listening server behind returned timed_out and lost the context's state, because every call waited for the guest event loop to drain.

  • A context call, and a one-shot evaluate, now complete when the top-level evaluation settles and their in-flight host calls finish.
  • The runtime then cancels leftover timers and immediates, closes leftover sockets, servers, dgram sockets, and child processes, and writes one summary line to stderr. Context globals survive.
  • One-shot execute keeps Node's behavior and waits for ref'd handles.
  • evaluate no longer needs a keep-alive interval. javascript.mdx documents the completion rule and the updated execution_busy behavior.
Context call (setInterval(() => {}, 50), globalThis.answer = 41), then answer + 1 main This PR
First call timed_out, context killed 41
Second call — 42

Known limits: a leftover HTTP/2 server or an open process.stdin read has no close hook yet, so a call that leaves one still ends at its timeout. Python contexts are unchanged.

A context call or JavaScript/TypeScript evaluation now completes when its top-level evaluation settles and its in-flight bridge calls finish, instead of waiting for the guest event loop to drain. Leftover timers and immediates are cancelled and ref'd sockets, servers, dgram sockets, and child processes are closed, with a summary on stderr. Context globals survive. One-shot execute keeps Node's wait-for-ref'd-handles behavior.

Previously a leftover setInterval or listening server turned a finished call into timed_out and killed the context. The evaluation wrapper no longer needs a keep-alive interval.

Fixes #1991
@github-actions

Copy link
Copy Markdown
Contributor

📟 Pip-Boy · 3fdc1a6

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

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

All 6 packages · linux-x64-gnu
package (linux-x64-gnu) @latest base this PR Δ vs base packages
@rivet-dev/agentos-core 458.2 MB 458.2 MB 458.2 MB 0 121 (0)
@rivet-dev/agentos-node-pty 7.6 KB 18.0 KB 18.0 KB 0 1 (0)
@rivet-dev/agentos-posix 253.6 MB 253.6 MB 253.6 MB 0 7 (0)
@rivet-dev/agentos-runtime-core 253.6 MB 253.6 MB 253.6 MB 0 6 (0)
@rivet-dev/agentos-sandbox 495.5 MB 495.5 MB 495.5 MB 0 177 (0)
@rivet-dev/agentos-toolchain 130.8 KB 141.2 KB 141.2 KB 0 2 (0)

🧹 Rust dependencies · cargo deny + cargo shear

check new in this PR fixed existing on base
advisories ✅ 0 0 25
licenses ✅ 0 0 0
sources ✅ 0 0 0
bans ✅ 0 0 0
unused ✅ 0 0 16

🦀 Binaries · publish Dockerfiles, --release

Base: main@8cc8f8b, the merge base.

artifact npm @latest base this PR Δ vs base
agentos-native-sidecar linux-x64-gnu 143.6 MB 143.6 MB 143.7 MB +127.9 KB (+0.1%)

⏱ Timing

job wall time slowest step
zizmor 7s checkout · 2s
changes 32s checkout · 28s
native · linux-x64-gnu 14m16s Build with the publish Dockerfile · 13m53s
hygiene 51s checkout · 23s
footprint 2m04s Pack this commit · 40s
⏭ self-test — skipped
report 18s setup-node · 4s
🔭 Full CI trace for this commit

One OpenTelemetry trace of CI and Pip-Boy for 3fdc1a6: 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 3fdc1a64733f57c76acc3cf90d62c6bbbdda01fa

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

Agent instruction: From a rivet-dev/agentos 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 b9ce935 into main Oct 21, 2026
16 checks passed
@eersnington
eersnington deleted the fix/context-call-completion branch October 21, 2026 15:03
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.

A leftover handle turns a finished context call into timed_out and clears the context

1 participant