diff --git a/htmltidy.js b/htmltidy.js
old mode 100644
new mode 100755
index 6e501da..d45fa1e
--- a/htmltidy.js
+++ b/htmltidy.js
@@ -127,7 +127,7 @@ function tidy(text, opts, cb) {
error+= data;
});
worker.on('end', function (code) {
- cb(error, result);
+ setImmediate(function(){cb(error, result);});
});
worker.end(text);
}