Skip to content

[P2] Bound SDK token acquisition and cleanup waits #26

Open

Description

@starmorph

Review finding R7, priority P2. Reviewed source: e112e51.

Assessment

Fix-benefit confidence Severity Difficulty Code size
85/100 60/100 80/100 60/100

Scores are engineering estimates, not calibrated probabilities or CVSS. Confidence rates improvement from the proposed fix; severity reflects this repository's prerequisites and safeguards. Higher difficulty/code-size scores mean more work.

The deadline gap is reproduced against the real SDK, but a safe solution must handle uncertain and late create results plus cleanup. This needs a technical design step before implementation.

Finding and verification

Evidence: The wrapper passes signals to exec/upload/download but directly awaits their SDK promises (src/sandbox/render/client.ts:97,122,126). The installed SDK first requests a connect token without the passed signal. Its control-plane client has no configured HTTP deadline. Termination is also awaited without a cleanup budget at line 144. The existing comment in sandbox.ts:94 acknowledges create/get limitations but does not cover these additional phases.

Trigger and verification: Using the real pinned SDK with a process-local fake transport, a token response delayed 80 ms held a nominal 5 ms exec deadline for approximately 83 ms. The token request had no supplied signal. A separate host probe showed a 25 ms provision budget still pending at 70 ms while a 180 ms create call was in flight.

Impact: A stalled token request can exceed application deadlines before the signal-aware data plane begins. A stalled cleanup can delay returning an already computed answer. Outer workflow and provider lifetime backstops remain useful, but do not make these host waits bounded.

Fix direction: Use a supported provider-owned bounded HTTP transport or upstream signal support for token/control-plane requests, plus a cleanup budget. Preserve eventual cleanup of uncertain or late create results; a bare Promise.race that forgets the eventual creation can leak resources until provider timeout.

Current SDK check: This gap remains in the versioned SDK 1.4.0 source. The public Render constructor has no fetch/timeout option; the exported SandboxesClient accepts a provider-owned API transport. Details and public API constraints are in the current SDK source and public constructor contract.

Regression: Delay each token phase and termination independently. Verify bounded return, no model work after cancellation, and cleanup of a late-created Sandbox. Exercise the real SDK transport, not only a fake method that already honors a signal.

Proposed implementation scope

SDK transport adapter/client, deadline and cleanup handling, real-transport contract tests, possible explicit transport dependency; roughly 4–7 files.

Keep this fix separate from unrelated refactors. Preserve the qualifications above; no real Render or paid model validation was performed during review.

Acceptance and verification

  • Add the focused regression described above and confirm it detects the current behavior.
  • Implement the selected fix without changing unrelated public behavior.
  • Run frozen dependency installation, pnpm typecheck, and the relevant existing tests; report failures and skipped checks.
  • Update docs/config migration where affected.
  • Record any required Render staging or snapshot-refresh validation before rollout.

Use a dedicated codex/issue-N-sandbox-transport-deadlines branch and a focused PR referencing this issue after the fix is selected.

Activity

  1. jacobprall commented on Oct 28, 2026

    @jacobprall
    Collaborator

    Status: #39 was closed in favor of fixing this in the SDK, filed as render-oss/sdk#31. #45 adds a 10-second cleanup budget for terminate in the meantime. Keep this open until the SDK forwards signals to connect-token requests and we upgrade from 1.3.0.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions