Skip to content

Thread-storage file route ignores Range, so a stored video cannot seek and does not play in Safari #4339

Closed

Description

@BartSoj

Summary

GET /api/v1/threads/<id>/thread-storage/files/<path> answers a Range request with 200 and the
whole file, and never sends Accept-Ranges. A <video> pointing at a stored mp4 therefore cannot
seek, and Safari (macOS and iOS), which requires byte-range responses for video, does not play it.
Agents routinely render videos into thread storage (e.g. a Remotion render); the natural way to
show one is a <video src> at this route.

Versions and environment

bb 0.43.4 desktop, macOS; source checked on main at 6984eba875135252cb203cfe363bfecfeeeb8ce0.

Steps to reproduce

  1. Put any mp4 in a thread's storage (here 4,032,142 bytes).
  2. curl -s -o /dev/null -D - -H 'Range: bytes=0-99' http://127.0.0.1:38886/api/v1/threads/<id>/thread-storage/files/clip.mp4

Expected vs actual

Expected 206 Partial Content, Content-Range: bytes 0-99/4032142, Accept-Ranges: bytes.
Actual:

HTTP/1.1 200 OK
content-length: 4032142
content-type: video/mp4

Evidence

The route passes only If-None-Match through; the file is read whole over host RPC:

async function serveThreadStorageRawFile(
deps: LoggedWorkSessionDeps,
threadId: string,
rawPath: string,
ifNoneMatch: string | undefined,
): Promise<Response> {
const filePath = parseSafeRelativeRoutePath(rawPath);
const target = await requireThreadStorageTarget(deps, { threadId });
return serveDaemonFileContent(
deps,
{
hostId: target.hostId,
...(!isHtmlPreviewPath(filePath.relativePath) ? { ifNoneMatch } : {}),
path: path.join(target.storagePath, filePath.relativePath),
rootPath: target.storagePath,
},
(result) =>
createRawFilePreviewResponse(result, filePath.relativePath, ifNoneMatch),
);
}

and
get(routes.storageFile, async (context) =>
serveThreadStorageRawFile(
deps,
context.req.param("id"),
context.req.param("filePath"),
context.req.header("if-none-match"),
),
);

Inference: because the whole file crosses the host RPC, the daemon's read cap (25 MiB for
non-image files, measured on 0.42.1) also bounds any video served here. A ranged read would lift
that for media as well.

What you ruled out

Not content-type (it is video/mp4), not caching (If-None-Match absent). Searched issues for
"Range", "206", "video", "seek" — nothing relevant; #3700 (PDF download) and #3439 (inline
previews) are adjacent.

Suggested priority and effort

Small, contained. Affects anyone viewing an agent-made video from storage, and bb's own previews if
they use this route. I can PR it once approved.

AGENT GENERATED

Activity

  1. BartSoj commented on Sep 25, 2026

    @BartSoj
    Author

    Live evidence from bb Connect (bb 0.43.4, <handle>.getbb.app), 2026-09-25. The same stored
    4,032,142-byte H.264 mp4 opened directly at
    /api/v1/threads/<id>/thread-storage/files/<name>.mp4 — top-level navigation, signed in, so the
    session cookie is sent:

    Browser Plays?
    Chrome, macOS yes
    Safari, macOS no
    Safari 26.6, iOS 18.7 no (crossed-out play button)
    Chrome, iOS (WebKit) no

    Every WebKit client refuses it and the one Blink client plays it — the pattern expected when a
    server answers Range with 200 and no Accept-Ranges (measured in the issue). Chrome on macOS plays the
    same file from the same URL, so it is not the encoding.

    Why loopback hides it (measured the same day from the signed-in Connect tab, same-origin fetch):
    over Connect the response carries no Content-Length — the body is re-streamed — and a
    Range: bytes=0-99 request still gets 200 and all 4,032,142 bytes. On loopback the response has
    Content-Length, and WebKit falls back to the whole-file 200 and plays. Without
    Content-Length and without 206, WebKit fails with MediaError 4, which is what every iOS browser
    shows. A branch that answers single ranges with 206 plays and seeks in WebKit in that streamed
    case: https://github.com/BartSoj/bb/tree/fix/thread-storage-range

    AGENT GENERATED

  2. added a commit that references this issue on Sep 25, 2026
    c730a01
  3. added theissue type on Sep 25, 2026
  4. added
    threads
    no-repro
    on Sep 25, 2026
  5. bb-slop-cop commented on Sep 25, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Preserved Bug · Medium priority · High effort · threads.

    ALREADY FIXED · high root-cause confidence. The former whole-file handler discarded Range; current main forwards the request to bounded, range-aware streaming. Both clean checkouts passed 121 route/stream tests, including 206, Content-Range, and Accept-Ranges. Safari/Connect playback was not tested.

    Reproduction and root-cause report · reproduction label: no-repro.

    No new PR: the fix is already merged in #4343 and present on trusted main.

    AGENT GENERATED

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-reprothreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions