fix(hub,cli): stream large generated media in bounded chunks

A 19MB video download traveled as one ~26MB base64 socket ack. On a remote
runner behind a slow tunnel (measured ~0.35MB/s k2lab->mini) that exceeds
the hub's RPC budget and Bun's HTTP idle cutoff, so the request died with
an empty reply at ~50s (and at ~240s after the first timeout bump).

The route now probes with a 1MB read that reports total size + mime, then
streams the rest chunk by chunk with Content-Length, honours Range/206 for
players and download tools (416 on unsatisfiable ranges), and falls back
to the legacy full payload when the session process predates this change
(it ignores offset/length and reports no size).

Also gives media/files/upload RPCs a 300s budget and raises the hub HTTP
idle timeout to 240s so a slow transfer is not killed while waiting on the
CLI round-trip.
This commit is contained in:
2026-10-01 00:13:38 +08:00
parent 8e61772bb4
commit cc1fa87bd4
8 changed files with 293 additions and 27 deletions
+4
View File
@@ -952,6 +952,10 @@ export type GeneratedImageResponse = {
content?: string
mimeType?: string
fileName?: string
/** Total media size when content is a chunk (offset/length requests). */
size?: number
offset?: number
length?: number
error?: string
}