stream request bodies through the photos sidecar

both forwarders buffered the whole request body into an ArrayBuffer before
re-sending it to Immich. with maxRequestBodySize at 4GB that put a phone's
video upload in the sidecar's heap for a hop that never reads the bytes.

callUpstream now sets duplex: 'half' so a stream is a legal body, matching
what createSidecarProxy already does on the platform side. the four JSON
callers are unaffected.

the platform proxy forwards no content-length, so the body already reached
us chunked; this extends that one hop to Immich. verified against the live
instance (3.1.0): bulk-upload-check round-trips a streamed body and returns
the right verdict.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-08 15:45:01 +00:00
co-authored by Claude Opus 5
parent ea59b5f1a7
commit 63f7a14b6c
3 changed files with 20 additions and 4 deletions
+2 -1
View File
@@ -268,7 +268,8 @@ async function forward(req: Request, url: URL, cfg: UpstreamConfig, userId: numb
path: `/api/${rest}`,
method: req.method,
query: search ? `?${search}` : '',
body: hasBody ? await req.arrayBuffer() : null,
// Streamed, not buffered — same reason as the unlocked forwarder in routes.ts.
body: hasBody ? req.body : null,
contentType: req.headers.get('content-type'),
range: req.headers.get('range'),
ifNoneMatch: req.headers.get('if-none-match'),