mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Show request duration warning after 240s for long requests
This commit is contained in:
parent
419a9c4367
commit
7bda141ca5
@ -114,15 +114,13 @@ export function handleApiRequest(handler: (req: NextRequest, options: any, reque
|
||||
"/api/latest/internal/external-db-sync/sequencer",
|
||||
"/api/latest/internal/external-db-sync/sync-engine",
|
||||
];
|
||||
if (!allowedLongRequestPaths.includes(req.nextUrl.pathname)) {
|
||||
const warnAfterSeconds = 12;
|
||||
runAsynchronously(async () => {
|
||||
await wait(warnAfterSeconds * 1000);
|
||||
if (!hasRequestFinished) {
|
||||
captureError("request-timeout-watcher", new Error(`Request with ID ${requestId} to ${req.method} ${req.nextUrl.pathname} has been running for ${warnAfterSeconds} seconds. Try to keep requests short. The request may be cancelled by the serverless provider if it takes too long.`));
|
||||
}
|
||||
});
|
||||
}
|
||||
const warnAfterSeconds = allowedLongRequestPaths.includes(req.nextUrl.pathname) ? 180 : 12;
|
||||
runAsynchronously(async () => {
|
||||
await wait(warnAfterSeconds * 1000);
|
||||
if (!hasRequestFinished) {
|
||||
captureError("request-timeout-watcher", new Error(`Request with ID ${requestId} to ${req.method} ${req.nextUrl.pathname} has been running for ${warnAfterSeconds} seconds. Try to keep requests short. The request may be cancelled by the serverless provider if it takes too long.`));
|
||||
}
|
||||
});
|
||||
|
||||
if (!disableExtendedLogging) console.log(`[API REQ] [${requestId}] ${req.method} ${censoredUrl}`);
|
||||
const timeStart = performance.now();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user