Spaces:
Running
Running
Ignore canceled media range streams
Browse files- src/server.ts +4 -0
src/server.ts
CHANGED
|
@@ -1253,6 +1253,10 @@ async function proxyAnalysisRequest(req: Request, res: Response) {
|
|
| 1253 |
|
| 1254 |
const analysisProxy = (req: Request, res: Response, next: NextFunction) => {
|
| 1255 |
void proxyAnalysisRequest(req, res).catch((error: unknown) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1256 |
if (res.headersSent) return res.destroy(error instanceof Error ? error : undefined);
|
| 1257 |
console.error("Analysis API proxy failed", error);
|
| 1258 |
return res.status(502).json({ error: "The analysis service is unavailable." });
|
|
|
|
| 1253 |
|
| 1254 |
const analysisProxy = (req: Request, res: Response, next: NextFunction) => {
|
| 1255 |
void proxyAnalysisRequest(req, res).catch((error: unknown) => {
|
| 1256 |
+
const code = error instanceof Error ? (error as NodeJS.ErrnoException).code : undefined;
|
| 1257 |
+
// Browsers cancel obsolete byte-range requests while seeking or changing cameras.
|
| 1258 |
+
// Treat the resulting closed stream as a normal client disconnect.
|
| 1259 |
+
if ((req.aborted || req.socket.destroyed) && code === "ERR_STREAM_PREMATURE_CLOSE") return;
|
| 1260 |
if (res.headersSent) return res.destroy(error instanceof Error ? error : undefined);
|
| 1261 |
console.error("Analysis API proxy failed", error);
|
| 1262 |
return res.status(502).json({ error: "The analysis service is unavailable." });
|