The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 15:30 UTC
perf(web): Open Source Licenses downloads its manifest once per session (#17119)
oliver committed
Oct 10, 2026 at 05:23 UTC
f7664fdf425555e0f85b74d904cfa4eaf57cf7af
1 file changed
+37
-13
apps/web/src/components/settings/OpenSourceLicenses.tsx
+37
-13
@@ -21,15 +21,35 @@ type LicenseManifestState =
21
| { readonly status: "error"; readonly message: string }
22
| { readonly status: "ready"; readonly manifest: ThirdPartyLicenseManifest };
23
24
-async function loadLicenseManifest(signal: AbortSignal): Promise<ThirdPartyLicenseManifest> {
25
- const response = await fetch(
26
- `${import.meta.env.BASE_URL.replace(/\/$/, "")}/third-party-licenses.json`,
27
- { signal },
28
- );
29
- if (!response.ok) {
30
- throw new Error(`The license manifest request failed with status ${String(response.status)}.`);
24
+let licenseManifestPromise: Promise<ThirdPartyLicenseManifest> | undefined;
25
+
26
+async function fetchLicenseManifest(): Promise<ThirdPartyLicenseManifest> {
27
+ const signal = AbortSignal.timeout(30_000);
28
+ try {
29
+ const response = await fetch(
30
+ `${import.meta.env.BASE_URL.replace(/\/$/, "")}/third-party-licenses.json`,
31
+ { signal },
32
+ );
33
+ if (!response.ok) {
34
+ throw new Error(
35
+ `The license manifest request failed with status ${String(response.status)}.`,
36
+ );
37
+ }
38
+ return decodeThirdPartyLicenseManifest((await response.json()) as unknown);
39
+ } catch (error) {
40
+ if (signal.aborted) {
41
+ throw new Error("The license manifest took too long to load.", { cause: error });
42
+ }
43
+ throw error;
44
}
32
- return decodeThirdPartyLicenseManifest((await response.json()) as unknown);
45
+}
46
+
47
+function loadLicenseManifest(): Promise<ThirdPartyLicenseManifest> {
48
+ licenseManifestPromise ??= fetchLicenseManifest().catch((error: unknown) => {
49
+ licenseManifestPromise = undefined;
50
+ throw error;
51
+ });
52
+ return licenseManifestPromise;
53
}
54
55
function LicenseNoticeRow({
@@ -198,19 +218,23 @@ export function OpenSourceLicensesPanel() {
218
const [requestVersion, setRequestVersion] = useState(0);
219
220
useEffect(() => {
201
- const controller = new AbortController();
221
+ let cancelled = false;
222
setState({ status: "loading" });
203
- void loadLicenseManifest(controller.signal).then(
204
- (manifest) => setState({ status: "ready", manifest }),
223
+ void loadLicenseManifest().then(
224
+ (manifest) => {
225
+ if (!cancelled) setState({ status: "ready", manifest });
226
+ },
227
(error: unknown) => {
206
- if (controller.signal.aborted) return;
228
+ if (cancelled) return;
229
setState({
230
status: "error",
231
message: error instanceof Error ? error.message : "The license manifest could not load.",
232
});
233
},
234
);
213
- return () => controller.abort();
235
+ return () => {
236
+ cancelled = true;
237
+ };
238
}, [requestVersion]);
239
240
const entries = state.status === "ready" ? state.manifest.entries : [];