Skip to content

Commit

Permalink
fix(): report load time when load brick failed
Browse files Browse the repository at this point in the history
  • Loading branch information
weareoutman committed Nov 14, 2024
1 parent 4beda0c commit bcf5e90
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/loader/src/stableLoadBricks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,20 @@ async function loadBrickModule(
const moduleName = `${type === "processors" || type === "editors" ? `./${type}/` : "./"}${
type === "editors" ? item.fullName : item.lastName
}`;
const start = performance.now();
try {
await loadSharedModule(pkgId, moduleName);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
const cost = Math.round(performance.now() - start);
throw new BrickLoadError(
`Load ${type} of "${item.fullName}" failed: ${(error as Error)?.message}`
`Load ${type} of "${item.fullName}" failed${
// istanbul ignore next
process.env.NODE_ENV === "test"
? ""
: ` (${cost > 1000 ? `${+(cost / 1000).toFixed(2)}s` : `${cost}ms`})`
}: ${(error as Error)?.message}`
);
}
}
Expand Down

0 comments on commit bcf5e90

Please sign in to comment.