Skip to content

Commit d0c9d41

Browse files
committed
Merge branch 'main' of https://github.com/oBusk/npm-diff.app into source-and-trust
2 parents 9ad1c50 + f3068a4 commit d0c9d41

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/lib/api/bundlephobia/bundlephobia.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ async function getPackage(spec: string): Promise<BundlephobiaResponse | null> {
5959
`[${spec}] Bundlephobia returned 500 Internal Server Error`,
6060
);
6161

62+
return null;
63+
} else if (response.status === 520) {
64+
// Found when Bundlephobia has cloudflare issues.
65+
// Like https://github.com/pastelsky/bundlephobia/issues/823
66+
// https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-520/
67+
// We cache for a while, it usually takes a while to come back.
68+
cacheLife("days");
69+
70+
console.warn(`[${spec}] Bundlephobia returned 520 Unknown Error`);
71+
6272
return null;
6373
} else {
6474
// For other, unexpected statuses, we cache briefly and log the error.

0 commit comments

Comments
 (0)