Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit b438ef0

Browse files
committed
fix: Handle local package database errors better (#8)
* Handle local package database errors better If a 'local' package doesn't exist, we can just not count it. * Better handling of missing local packages
1 parent ab2e349 commit b438ef0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/metrics/databaseMetrics.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ async function* iterateLocalDatabase(
3535
// do the async fetching loop
3636
const packageList = await getPkgList();
3737
for (const packageName of packageList) {
38-
const packageMeta = await getPkgMetadata(packageName);
38+
// handle missing packages: https://github.com/freight-hub/verdaccio-openmetrics/issues/7
39+
const packageMeta = await getPkgMetadata(packageName).catch(err => {
40+
const reason = (err as Error).message || `${err}`;
41+
// eslint-disable-next-line no-console
42+
console.error(`WARN: Failed to fetch local package "${packageName}" for database metrics: ${reason}`);
43+
return null;
44+
});
3945
if (packageMeta) {
4046
yield packageMeta;
4147
}

0 commit comments

Comments
 (0)