Skip to content

Commit 7bda141

Browse files
committed
Show request duration warning after 240s for long requests
1 parent 419a9c4 commit 7bda141

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

apps/backend/src/route-handlers/smart-route-handler.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,13 @@ export function handleApiRequest(handler: (req: NextRequest, options: any, reque
114114
"/api/latest/internal/external-db-sync/sequencer",
115115
"/api/latest/internal/external-db-sync/sync-engine",
116116
];
117-
if (!allowedLongRequestPaths.includes(req.nextUrl.pathname)) {
118-
const warnAfterSeconds = 12;
119-
runAsynchronously(async () => {
120-
await wait(warnAfterSeconds * 1000);
121-
if (!hasRequestFinished) {
122-
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.`));
123-
}
124-
});
125-
}
117+
const warnAfterSeconds = allowedLongRequestPaths.includes(req.nextUrl.pathname) ? 180 : 12;
118+
runAsynchronously(async () => {
119+
await wait(warnAfterSeconds * 1000);
120+
if (!hasRequestFinished) {
121+
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.`));
122+
}
123+
});
126124

127125
if (!disableExtendedLogging) console.log(`[API REQ] [${requestId}] ${req.method} ${censoredUrl}`);
128126
const timeStart = performance.now();

0 commit comments

Comments
 (0)