Mitigate long loading times on spaces with many files. (#260)

This commit is contained in:
Steven H
2024-03-14 11:41:11 +00:00
committed by GitHub
parent d0eebceacf
commit e5a9d16d7e
4 changed files with 25 additions and 7 deletions
+5 -2
View File
@@ -3,9 +3,12 @@ import * as Sentry from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
Sentry.init({
dsn,
tracesSampleRate: 0.01,
debug: false,
dsn,
integrations: [],
enableTracing: false,
beforeSendTransaction: () => {
return null;
},
});
}
+10 -2
View File
@@ -3,8 +3,16 @@ import * as Sentry from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
Sentry.init({
dsn,
tracesSampleRate: 0.01,
debug: false,
dsn,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
enableTracing: false,
// Disable transactions as it creates additional requests in an env where subrequests are limited.
// https://docs.sentry.io/platforms/node/configuration/filtering/#using--3
beforeSendTransaction: () => {
return null;
},
});
}
+3
View File
@@ -482,6 +482,9 @@ const getRevisionAllFiles = cache(
return cacheResponse(response, { ...immutableCacheTtl_7days, data: files });
},
{
timeout: 60 * 1000,
}
);
/**
+7 -3
View File
@@ -63,8 +63,14 @@ export function cache<Args extends any[], Result>(
/** Default ttl (in seconds) */
defaultTtl?: number;
/** When a request to the underlying resource will timeout. */
timeout?: number;
} = {},
): CacheFunction<Args, Result> {
// We stop everything after 10s to avoid pending requests
const timeout = options.timeout ?? 1000 * 10;
const revalidate = singletonMap(
async (key: string, signal: AbortSignal | undefined, ...args: Args) => {
return await trace(
@@ -131,9 +137,7 @@ export function cache<Args extends any[], Result>(
},
{
signal,
// We stop everything after 10s to avoid pending requests
timeout: 10 * 1000,
timeout,
// We give 70ms to the caches to respond, otherwise we start fallbacking to the actual fetch
// It should represents a bit more than the 90th percentile of the KV cache response time