mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-03-27 17:52:35 +01:00
fix: implement retry logic to prevent data fetching timeouts
This commit is contained in:
@@ -231,7 +231,11 @@ async function generateGameListMd(target: GameTarget) {
|
|||||||
const isFileAvail = {
|
const isFileAvail = {
|
||||||
orig: await (async () => {
|
orig: await (async () => {
|
||||||
try {
|
try {
|
||||||
await ky.head(f.url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
|
await ky.head(f.url, {
|
||||||
|
headers: { 'User-Agent': appConfig.network.userAgent.minimum },
|
||||||
|
timeout: appConfig.network.timeout,
|
||||||
|
retry: { limit: appConfig.network.retryCount },
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
@@ -316,7 +320,11 @@ async function generatePatchListMd(target: GameTarget) {
|
|||||||
const isFileAvail = {
|
const isFileAvail = {
|
||||||
orig: await (async () => {
|
orig: await (async () => {
|
||||||
try {
|
try {
|
||||||
await ky.head(e.rsp.patch!.url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
|
await ky.head(e.rsp.patch!.url, {
|
||||||
|
headers: { 'User-Agent': appConfig.network.userAgent.minimum },
|
||||||
|
timeout: appConfig.network.timeout,
|
||||||
|
retry: { limit: appConfig.network.retryCount },
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
@@ -344,7 +352,11 @@ async function generatePatchListMd(target: GameTarget) {
|
|||||||
const isFileAvail = {
|
const isFileAvail = {
|
||||||
orig: await (async () => {
|
orig: await (async () => {
|
||||||
try {
|
try {
|
||||||
await ky.head(f.url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
|
await ky.head(f.url, {
|
||||||
|
headers: { 'User-Agent': appConfig.network.userAgent.minimum },
|
||||||
|
timeout: appConfig.network.timeout,
|
||||||
|
retry: { limit: appConfig.network.retryCount },
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
@@ -783,7 +795,11 @@ async function fetchAndSaveAllGameResRawData(gameTargets: GameTarget[]) {
|
|||||||
if (!(await Bun.file(localFilePath).exists())) {
|
if (!(await Bun.file(localFilePath).exists())) {
|
||||||
try {
|
try {
|
||||||
const rsp = await ky
|
const rsp = await ky
|
||||||
.get(urlObj.href, { headers: { 'User-Agent': appConfig.network.userAgent.minimum } })
|
.get(urlObj.href, {
|
||||||
|
headers: { 'User-Agent': appConfig.network.userAgent.minimum },
|
||||||
|
timeout: appConfig.network.timeout,
|
||||||
|
retry: { limit: appConfig.network.retryCount },
|
||||||
|
})
|
||||||
.bytes();
|
.bytes();
|
||||||
await Bun.write(localFilePath, rsp);
|
await Bun.write(localFilePath, rsp);
|
||||||
wroteFiles.push(localFilePath);
|
wroteFiles.push(localFilePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user