Skip to content

Commit 92ae6c7

Browse files
committed
fix(): handle basic load failed
1 parent 4c48eea commit 92ae6c7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/loader/src/stableLoadBricks.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, jest, test, expect } from "@jest/globals";
2-
import {
2+
import type {
33
loadBricksImperatively as _loadBricksImperatively,
44
loadProcessorsImperatively as _loadProcessorsImperatively,
55
loadEditorsImperatively as _loadEditorsImperatively,

packages/loader/src/stableLoadBricks.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ interface BrickPackage {
1515
}
1616

1717
let resolveBasicPkg: () => void;
18+
let rejectBasicPkg: (e: unknown) => void;
1819
let basicPkgWillBeResolved = false;
19-
const waitBasicPkg = new Promise<void>((resolve) => {
20+
const waitBasicPkg = new Promise<void>((resolve, reject) => {
2021
resolveBasicPkg = resolve;
22+
rejectBasicPkg = reject;
2123
});
2224

2325
export function flushStableLoadBricks(): void {
@@ -264,7 +266,9 @@ async function enqueueStableLoad(
264266
// Packages other than BASIC will wait for an extra micro-task tick.
265267
if (!basicPkgWillBeResolved) {
266268
basicPkgWillBeResolved = true;
267-
tempPromise.then(() => Promise.resolve()).then(resolveBasicPkg);
269+
tempPromise
270+
.then(() => Promise.resolve())
271+
.then(resolveBasicPkg, rejectBasicPkg);
268272
}
269273
basicPkgPromise = tempPromise.then(() =>
270274
Promise.all(
@@ -310,7 +314,7 @@ async function enqueueStableLoad(
310314
return adapter.resolve(
311315
v2Adapter.filePath,
312316
type === "editors"
313-
? pkg.propertyEditorsJsFilePath ?? pkg.filePath
317+
? (pkg.propertyEditorsJsFilePath ?? pkg.filePath)
314318
: pkg.filePath,
315319
type === "bricks"
316320
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

0 commit comments

Comments
 (0)