Skip to content

Commit f5c1c1b

Browse files
committed
fix: Only return null for crawl errors, not all extension in chromeExtensions
1 parent cee1c40 commit f5c1c1b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/services/chrome-service.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ export function createChromeService() {
66
const loader = createCachedDataLoader<
77
string,
88
Gql.ChromeExtension | undefined
9-
>(HOUR_MS, (ids) =>
10-
Promise.all(ids.map((id) => chrome.crawlExtension(id, "en"))),
11-
);
9+
>(HOUR_MS, async (ids) => {
10+
const results = await Promise.allSettled(
11+
ids.map((id) => chrome.crawlExtension(id, "en")),
12+
);
13+
return results.map((res) =>
14+
res.status === "fulfilled" ? res.value : res.reason,
15+
);
16+
});
1217

1318
return {
1419
getExtension: (id: string) => loader.load(id),
1520
getExtensions: async (ids: string[]) => {
1621
const result = await loader.loadMany(ids);
17-
return result.map((item) => {
18-
if (item == null) return undefined;
22+
return result.map((item, index) => {
1923
if (item instanceof Error) {
20-
console.warn("Error fetching multiple extensions:", item);
24+
console.warn("Error loading extension:", ids[index], item);
2125
return undefined;
2226
}
2327
return item;

0 commit comments

Comments
 (0)