Skip to content

Commit 641a509

Browse files
committed
fix: Only fetch endpoints once
1 parent 3686c9c commit 641a509

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

updater/warframe_exports.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const CONTENT_URL = "https://content.warframe.com";
55
const ORIGIN_URL =
66
process.env.WARFRAME_ORIGIN_PROXY ?? "https://origin.warframe.com";
77

8-
let endpoints;
8+
let endpointsPromise;
99

1010
function parseDamagedJSON(json) {
1111
return JSON.parse(json.replace(/\\\"/g, "'").replace(/\n|\r|\\/g, ""));
@@ -28,16 +28,18 @@ async function fetchEndpoints() {
2828
);
2929
}
3030

31-
endpoints = lzma
31+
return lzma
3232
.decompress(Buffer.from(await response.arrayBuffer()))
3333
.split("\n");
3434
}
3535

3636
export async function fetchEndpoint(endpoint) {
37-
if (!endpoints) {
38-
await fetchEndpoints();
37+
if (!endpointsPromise) {
38+
endpointsPromise = fetchEndpoints();
3939
}
4040

41+
const endpoints = await endpointsPromise;
42+
4143
return parseDamagedJSON(
4244
await (
4345
await fetch(

0 commit comments

Comments
 (0)