Explorar o código

Try to handle zlib errors

shamoon %!s(int64=2) %!d(string=hai) anos
pai
achega
abcea88d0a
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      src/utils/proxy/http.js

+ 7 - 0
src/utils/proxy/http.js

@@ -33,6 +33,13 @@ function handleRequest(requestor, url, params) {
       const contentEncoding = response.headers['content-encoding']?.trim().toLowerCase();
 
       let responseContent = response;
+
+      // zlib errors
+      responseContent.on("error", (e) => {
+        logger.error(e);
+        responseContent = response; // fallback
+      });
+
       if (contentEncoding === 'gzip' || contentEncoding === 'deflate') {
         responseContent = createUnzip();
         response.pipe(responseContent);