2 parents 9ad1c50 + f3068a4 commit d0c9d41Copy full SHA for d0c9d41
1 file changed
src/lib/api/bundlephobia/bundlephobia.ts
@@ -59,6 +59,16 @@ async function getPackage(spec: string): Promise<BundlephobiaResponse | null> {
59
`[${spec}] Bundlephobia returned 500 Internal Server Error`,
60
);
61
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
72
return null;
73
} else {
74
// For other, unexpected statuses, we cache briefly and log the error.
0 commit comments