浏览代码

Try to handle zlib errors

shamoon 2 年之前
父节点
当前提交
abcea88d0a
共有 1 个文件被更改,包括 7 次插入0 次删除
  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);