fix(streaming): end response on client disconnect during asset pipe
When a client disconnects mid-stream, headers are already sent so the catch block now calls response.end() before returning, preventing the socket from being left open and crashing the server. Fixes #445.
This commit is contained in:
@@ -178,7 +178,10 @@ export async function pipeAsset(url: string, response: Response, headers?: Recor
|
||||
await pipeline(Readable.fromWeb(resp.body as any), response);
|
||||
}
|
||||
} catch (error) {
|
||||
if (response.headersSent) return;
|
||||
if (response.headersSent) {
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
if (error instanceof SsrfBlockedError) {
|
||||
response.status(400).json({ error: error.message });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user