Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn committed Jun 25, 2024
1 parent 4a358e6 commit 3d6c17b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function basicProxy(proxy_url = ""): Handler {
testResWithoutHeaders.statusText
);

const fetchAndHandleBunCertificateError = async () => {
const fetchAndHandleBunCertificateError = async (): Promise<Response> => {
try {
console.log("fetchAndHandleBunCertificateError: Fetching", url);
return await fetch(url, {
Expand All @@ -80,9 +80,15 @@ function basicProxy(proxy_url = ""): Handler {
body: blob.size > 0 ? blob : undefined,
});
} catch (error) {
console.error(
"fetchAndHandleBunCertificateError: Error",
error,
error.name,
error.message
);
if (
error ===
"UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate"
error.name === "UNABLE_TO_GET_ISSUER_CERT" ||
error.message === "unable to get issuer certificate"
) {
console.log(
"fetchAndHandleBunCertificateError: Retrying after sleep",
Expand All @@ -93,6 +99,8 @@ function basicProxy(proxy_url = ""): Handler {

return fetchAndHandleBunCertificateError();
}

throw error;
}
};

Expand Down

0 comments on commit 3d6c17b

Please sign in to comment.