Prechádzať zdrojové kódy

Fix YLT freezing the queue when an incorrect gzip header is sent on a file

Gaël Métais 10 rokov pred
rodič
commit
e342a88f7d

+ 1 - 1
lib/tools/weightChecker/fileMinifier.js

@@ -121,7 +121,7 @@ var FileMinifier = function() {
             });
 
         } else {
-            debug('Not minfiable type or already minified');
+            debug('Not minifiable type or already minified');
             deferred.resolve(entry);
         }
 

+ 3 - 1
lib/tools/weightChecker/gzipCompressor.js

@@ -6,6 +6,7 @@ var zlib    = require('zlib');
 var GzipCompressor = function() {
 
     function compressFile(entry) {
+        debug('Entering compressFile');
         return gzipUncompressedFile(entry)
 
         .then(gzipOptimizedFile);
@@ -41,7 +42,7 @@ var GzipCompressor = function() {
                 }
             });
         } else {
-            
+            debug('Compression not needed');
             deferred.resolve(entry);
         }
 
@@ -73,6 +74,7 @@ var GzipCompressor = function() {
                 }
             });
         } else {
+            debug('Compressing optimized file not needed');
             deferred.resolve(entry);
         }
 

+ 7 - 0
lib/tools/weightChecker/weightChecker.js

@@ -46,6 +46,7 @@ var WeightChecker = function() {
                 .then(gzipCompressor.compressFile)
 
                 .then(function(newEntry) {
+                    debug('File %s - Redownloaded, optimized, minified, compressed: done', entry.url);
                     callback(null, newEntry);
                 })
 
@@ -439,7 +440,9 @@ var WeightChecker = function() {
                         isCompressed = true;
                         tally();
                     }).on('error', function(err) {
+                        debug('Error while decoding %s', requestOptions.url);
                         debug(err);
+                        callback(err);
                     });
 
                     res.on('data', function (data) {
@@ -459,7 +462,9 @@ var WeightChecker = function() {
                         isCompressed = true;
                         tally();
                     }).on('error', function(err) {
+                        debug('Error while decoding %s', requestOptions.url);
                         debug(err);
+                        callback(err);
                     });
 
                     res.on('data', function (data) {
@@ -489,6 +494,8 @@ var WeightChecker = function() {
         })
 
         .on('error', function(err) {
+            debug('Error while downloading %s', requestOptions.url);
+            debug(err);
             callback(err);
         });
     }