Skip to content

fix(sandbox): timeout Lambda MicroVM requests - #15974

Open
abhinavkr26104 wants to merge 2 commits into
langfuse:mainfrom
abhinavkr26104:fix/15956-lambda-microvm-request-timeout
Open

abhinavkr26104 wants to merge 2 commits into
langfuse:mainfrom
abhinavkr26104:fix/15956-lambda-microvm-request-timeout

Conversation

@abhinavkr26104

@abhinavkr26104 abhinavkr26104 commented Aug 11, 2026 •

Copy link
Copy Markdown

Summary

  • abort Lambda MicroVM sandbox operation requests after a bounded timeout
  • preserve the requested bash execution budget with a five-second transport grace period
  • cap each bridge health probe to the remaining readiness deadline, including response-body reads
  • add regressions for hung sandbox operations and hung health probes

Impacted packages

  • @langfuse/shared
  • web server unit tests

Verification

  • pnpm --filter @langfuse/shared run build (passes)
  • pnpm --filter @langfuse/shared run lint (passes)
  • pnpm --filter worker run typecheck (passes)
  • pnpm --filter web run test src/tests/server/unit/in-app-agent-lambda-microvm-provider.servertest.ts (Test Files 1 passed (1); Tests 5 passed (5))
  • pnpm exec prettier --check on both changed files (passes)
  • git diff upstream/main...HEAD --check (passes)

Notes

  • The local machine runs Node 22 while the repo requires Node 24. Node 22 globSync returns Windows backslash paths, so the focused test used a temporary uncommitted path normalization to select the normal server-shared-source-unit project; CI runs the committed config on Node 24.
  • pnpm run lint did not complete locally and was stopped after hanging without output; the focused shared lint passed.
  • This change adds no new user-configurable URL or redirect behavior; the endpoint remains AWS-provided.

Closes #15956

Greptile Summary

This PR adds AbortSignal-based time limits to Lambda MicroVM sandbox operations and bridge health probes, with additional regression tests for hung requests.

  • Gives bash requests their execution budget plus five seconds of transport grace.
  • Applies a fixed timeout to other sandbox operations.
  • Bounds health-fetch and response-body processing by the remaining readiness deadline.
  • Adds fake-timer tests covering hung operation and health requests.

Confidence Score: 4/5

The PR should not merge until auth-token acquisition is included in the bridge readiness deadline, otherwise session creation can still hang beyond the promised bound.

The health request and body are now abortable, but every probe first awaits an AWS SDK auth-token request without a timeout or outer guard, leaving ensureSession unbounded under a stalled token request.

Files Needing Attention: packages/shared/src/in-app-agent/server/sandbox/providers/lambdaMicrovm.ts

Sequence Diagram

sequenceDiagram
  participant Session as ensureSession
  participant Bridge as waitForBridge
  participant AWS as Auth-token API
  participant Health as Bridge /health
  Session->>Bridge: wait for readiness (30s target)
  Bridge->>AWS: createMicrovmAuthToken
  Note over Bridge,AWS: No remaining-deadline timeout
  AWS-->>Bridge: token after unbounded delay
  Bridge->>Bridge: calculate remainingMs
  alt Deadline remains
    Bridge->>Health: fetch with AbortSignal(remainingMs)
    Health-->>Bridge: health result
  else Deadline expired
    Bridge-->>Session: readiness failure after excess wall time
  end
Loading
Prompt To Fix All With AI
### Issue 1
packages/shared/src/in-app-agent/server/sandbox/providers/lambdaMicrovm.ts:381
**Auth request escapes readiness deadline**

When the Lambda MicroVM auth-token API stalls or exceeds the remaining readiness window, `waitForBridge` awaits it before calculating `remainingMs`, causing `ensureSession` to remain blocked beyond the intended 30-second bound.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(sandbox): timeout Lambda MicroVM req..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug-fix-mar-26 labels Aug 11, 2026
@CLAassistant

CLAassistant commented Aug 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix-mar-26 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Lambda MicroVM sandbox requests have no timeout

2 participants