Skip to content

Commit 499d192

Browse files
committed
fix(web): a stalled license manifest request no longer sticks
1 parent 3e4ee42 commit 499d192

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎apps/web/src/components/settings/OpenSourceLicenses.tsx‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@ type LicenseManifestState =
2323
let licenseManifestPromise: Promise<ThirdPartyLicenseManifest> | undefined;
2424

2525
async function fetchLicenseManifest(): Promise<ThirdPartyLicenseManifest> {
26-
const response = await fetch(
27-
`${import.meta.env.BASE_URL.replace(/\/$/, "")}/third-party-licenses.json`,
28-
);
29-
if (!response.ok) {
30-
throw new Error(`The license manifest request failed with status ${String(response.status)}.`);
26+
const signal = AbortSignal.timeout(30_000);
27+
try {
28+
const response = await fetch(
29+
`${import.meta.env.BASE_URL.replace(/\/$/, "")}/third-party-licenses.json`,
30+
{ signal },
31+
);
32+
if (!response.ok) {
33+
throw new Error(
34+
`The license manifest request failed with status ${String(response.status)}.`,
35+
);
36+
}
37+
return decodeThirdPartyLicenseManifest((await response.json()) as unknown);
38+
} catch (error) {
39+
if (signal.aborted) {
40+
throw new Error("The license manifest took too long to load.", { cause: error });
41+
}
42+
throw error;
3143
}
32-
return decodeThirdPartyLicenseManifest((await response.json()) as unknown);
3344
}
3445

3546
function loadLicenseManifest(): Promise<ThirdPartyLicenseManifest> {

0 commit comments

Comments
 (0)