fixes server blowing up when a streaming request drops out
This commit is contained in:
parent
be1e672e68
commit
4dc9c649d8
|
@ -294,14 +294,15 @@ const handleDownstreamErrors: ProxyResHandlerWithBody = async (
|
||||||
throw new Error(errorPayload.error?.message);
|
throw new Error(errorPayload.error?.message);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Handles errors in the request rewriter pipeline. */
|
/** Handles errors in rewriter pipelines. */
|
||||||
export const handleInternalError: httpProxy.ErrorCallback = (
|
export const handleInternalError: httpProxy.ErrorCallback = (
|
||||||
err,
|
err,
|
||||||
_req,
|
_req,
|
||||||
res
|
res
|
||||||
) => {
|
) => {
|
||||||
logger.error({ error: err }, "Error in proxy request pipeline.");
|
logger.error({ error: err }, "Error in http-proxy-middleware pipeline.");
|
||||||
|
// headers might have already been sent
|
||||||
|
try {
|
||||||
(res as http.ServerResponse).writeHead(500, {
|
(res as http.ServerResponse).writeHead(500, {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
});
|
});
|
||||||
|
@ -315,6 +316,9 @@ export const handleInternalError: httpProxy.ErrorCallback = (
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error({ error: e }, "Error writing error response headers, giving up.");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const incrementKeyUsage: ProxyResHandlerWithBody = async (_proxyRes, req) => {
|
const incrementKeyUsage: ProxyResHandlerWithBody = async (_proxyRes, req) => {
|
||||||
|
|
Loading…
Reference in New Issue