Skip to content

Commit cd3e143

Browse files
committed
Retry unpkg requests
1 parent 55dacdc commit cd3e143

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

deploy/deployChangedPackages.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { generateChangelogFrom } from "../lib/changelog.js";
1414
import { packages } from "./createTypesPackages.js";
1515
import { fileURLToPath } from "node:url";
1616
import fetch from "node-fetch";
17+
import pRetry from 'p-retry';
18+
1719

1820
verify();
1921

@@ -164,8 +166,18 @@ function verify() {
164166
}
165167

166168
/** @param {string} filepath */
167-
function getFileFromUnpkg(filepath) {
168-
return fetch(`https://unpkg.com/${filepath}`).then((r) => r.text());
169+
async function getFileFromUnpkg(filepath) {
170+
return pRetry(async () => {
171+
const resp = await fetch(`https://unpkg.com/${filepath}`);
172+
if (resp.ok) {
173+
return resp.text();
174+
}
175+
if (resp.status === 404) {
176+
return "";
177+
}
178+
console.error(`Unexpected response status: ${resp.status}`);
179+
throw new Error(resp.statusText);
180+
});
169181
}
170182

171183
/** @param {string} dir */

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"jsonc-parser": "^3.3.1",
6161
"kdljs": "^0.3.0",
6262
"node-fetch": "^3.3.2",
63+
"p-retry": "^7.1.0",
6364
"prettier": "^3.6.2",
6465
"print-diff": "^2.0.0",
6566
"typescript": "^5.9.2",

0 commit comments

Comments
 (0)