Skip to content

Stream sandbox file downloads end to end #283

Description

@lamenting-hawthorn

Problem

Sandbox file downloads currently buffer the complete file in each provider and then copy that buffer again into the HTTP response. The route contains a TODO to stream the response, but the current SandboxProvider.downloadFile contract and all implementations return Promise<Buffer>.

A route-only ReadableStream wrapper would not reduce peak memory because the provider has already materialized the complete file.

Proposed direction

Introduce a genuinely incremental provider contract, then stream it through the turns download route while preserving the current ownership/path checks, maximum file-size enforcement, response headers, and error mapping.

Likely surfaces:

  • SandboxProvider file-download contract
  • Daytona provider
  • TFY sandbox transport
  • local sandbox provider
  • turns download route
  • provider contract and route tests

Design questions

  • Should the provider return a Web ReadableStream<Uint8Array>, an async iterable, or a response object containing stream plus known size?
  • Does the Daytona SDK expose a streaming file API, or is a lower-level transport required?
  • What chunked endpoint/protocol should the TFY sandbox use instead of base64 embedded in an exec result?
  • Is a temporary buffered compatibility fallback acceptable, or should the contract change only when every provider streams genuinely?

Acceptance criteria

  • Download bytes begin reaching the client before the complete file is loaded.
  • Peak application memory is bounded by chunk/backpressure behavior rather than file size.
  • Existing maximum-size and tenant/path controls remain enforced.
  • Client cancellation stops provider reads.
  • Provider contract tests verify progressive delivery and error behavior.

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