Fixes #524 - schedules subsequent inlining in next tick.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 17 Apr 2015 07:15:13 +0000 (08:15 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 17 Apr 2015 07:17:39 +0000 (08:17 +0100)
We don't need to call `response.end()` as it's called automatically
per spec: https://nodejs.org/api/http.html#http_http_get_options_callback

It may help solve the timeouts issue but certainly won't hurt.

History.md
lib/imports/inliner.js

index 0299202..beae4a0 100644 (file)
@@ -19,6 +19,7 @@
 * Fixed issue [#507](https://github.com/jakubpawlowicz/clean-css/issues/507) - merging longhands into many shorthands.
 * Fixed issue [#508](https://github.com/jakubpawlowicz/clean-css/issues/508) - removing duplicate media queries.
 * Fixed issue [#521](https://github.com/jakubpawlowicz/clean-css/issues/521) - unit optimizations inside `calc()`.
+* Fixed issue [#524](https://github.com/jakubpawlowicz/clean-css/issues/524) - timeouts in `@import` inlining.
 * Fixed issue [#526](https://github.com/jakubpawlowicz/clean-css/issues/526) - shorthand overriding into a function.
 * Fixed issue [#528](https://github.com/jakubpawlowicz/clean-css/issues/528) - better support for IE<9 hacks.
 * Fixed issue [#529](https://github.com/jakubpawlowicz/clean-css/issues/529) - wrong font weight minification.
index a58c26d..553a847 100644 (file)
@@ -241,7 +241,9 @@ function inlineRemoteResource(importedFile, mediaQuery, context) {
     context.errors.push('Broken @import declaration of "' + importedUrl + '" - ' + message);
     restoreImport(importedUrl, mediaQuery, context);
 
-    processNext(context);
+    process.nextTick(function () {
+      processNext(context);
+    });
   }
 
   var requestOptions = override(url.parse(importedUrl), context.inliner.request);
@@ -274,7 +276,9 @@ function inlineRemoteResource(importedFile, mediaQuery, context) {
         relativeTo: parsedUrl.protocol + '//' + parsedUrl.host + parsedUrl.pathname
       });
 
-      importFrom(importedData, newContext);
+      process.nextTick(function () {
+        importFrom(importedData, newContext);
+      });
     });
   })
   .on('error', function(res) {