Skip to content

Commit 7c94eba

Browse files
Fixes #36
Improved logging to note missing bundles, properly process logged errors
1 parent 09c1126 commit 7c94eba

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/bundle-orchestrator.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,20 @@ export class BundleOrchestrator extends Transform {
201201
try {
202202
// Produce error if there are bundles without all requirements
203203
if (this.scriptBundles.size > 0 || this.styleBundles.size > 0) {
204-
throw new Error("Stream completed before all bundles received their dependencies");
204+
const missingBundles: {
205+
type: BundleType,
206+
name: string,
207+
remainingFiles: string[],
208+
}[] = [];
209+
for (const bundle of this.scriptBundles) {
210+
missingBundles.push(bundle.report());
211+
}
212+
for (const bundle of this.styleBundles) {
213+
missingBundles.push(bundle.report());
214+
}
215+
const errMessage = "Stream completed before all bundles received their dependencies";
216+
this.logger.error(errMessage, missingBundles);
217+
throw new Error(errMessage);
205218
}
206219

207220
// Invoke results callback
@@ -210,7 +223,7 @@ export class BundleOrchestrator extends Transform {
210223
callback();
211224
}
212225
catch (error) {
213-
this.logger.error("_flush completed with error", { error });
226+
this.logger.error("_flush completed with error", { error: error?.toString() ?? error });
214227
callback(new PluginError(PluginName, error));
215228
}
216229
}

src/bundle.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,16 @@ export class Bundle {
142142
return false;
143143
}
144144
}
145+
146+
/**
147+
* Returns an object used for reporting bundle status when the stream completes before all required
148+
* files have been received.
149+
*/
150+
public report() {
151+
return {
152+
type: this.type,
153+
name: this.name,
154+
remainingFiles: this.remainingPaths.slice(),
155+
};
156+
}
145157
}

0 commit comments

Comments
 (0)