Skip to content

Commit 19832ec

Browse files
committed
fix(deps): pass along result for dependencies
1 parent 47ba43e commit 19832ec

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/WorkerPool.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class PoolWorker {
103103
this.activeJobs -= 1;
104104
this.onJobDone();
105105
if (err) {
106-
jobCallback(err instanceof Error ? err : new Error(err));
106+
jobCallback(err instanceof Error ? err : new Error(err), arg);
107107
} else {
108108
jobCallback(null, arg);
109109
}
@@ -114,22 +114,24 @@ class PoolWorker {
114114
callback(eachErr);
115115
return;
116116
}
117+
let bufferPosition = 0;
118+
if (result.result) {
119+
result.result = result.result.map((r) => {
120+
if (r.buffer) {
121+
const buffer = buffers[bufferPosition];
122+
bufferPosition += 1;
123+
if (r.string) {
124+
return buffer.toString('utf-8');
125+
}
126+
return buffer;
127+
}
128+
return r.data;
129+
});
130+
}
117131
if (error) {
118-
callback(this.fromErrorObj(error));
132+
callback(this.fromErrorObj(error), result);
119133
return;
120134
}
121-
let bufferPosition = 0;
122-
result.result = result.result.map((r) => {
123-
if (r.buffer) {
124-
const buffer = buffers[bufferPosition];
125-
bufferPosition += 1;
126-
if (r.string) {
127-
return buffer.toString('utf-8');
128-
}
129-
return buffer;
130-
}
131-
return r.data;
132-
});
133135
callback(null, result);
134136
});
135137
break;

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ function pitch() {
2020
resolve: this.resolve,
2121
optionsContext: this.options.context,
2222
}, (err, r) => {
23+
if (r) {
24+
r.fileDependencies.forEach(d => this.addDependency(d));
25+
r.contextDependencies.forEach(d => this.addContextDependency(d));
26+
}
2327
if (err) {
2428
callback(err);
2529
return;
2630
}
27-
r.fileDependencies.forEach(d => this.addDependency(d));
28-
r.contextDependencies.forEach(d => this.addContextDependency(d));
2931
callback(null, ...r.result);
3032
});
3133
}

0 commit comments

Comments
 (0)