Permalink
Browse files

fix error propagation from worker

1 parent c29a430 commit 1f689ae6dffc70da0f7fb7de05b9a35e6a4ca9e3 @alexlamsl alexlamsl committed Nov 21, 2016
Showing with 10 additions and 2 deletions.
  1. +7 −1 assets/master.js
  2. +3 −1 assets/worker.js
View
@@ -22,7 +22,13 @@
worker.onmessage = function() {
minify = function(value, options, callback, errorback) {
worker.onmessage = function(event) {
- (typeof event.data === 'string' ? callback : errorback)(event.data);
+ var data = event.data;
+ if (data.error) {
+ errorback(data.error);
+ }
+ else {
+ callback(data);
+ }
};
worker.postMessage({
value: value,
View
@@ -12,7 +12,9 @@
postMessage(minify(event.data.value, options));
}
catch (err) {
- postMessage(err);
+ postMessage({
+ error: err + ''
+ });
}
});
postMessage(null);

0 comments on commit 1f689ae

Please sign in to comment.