Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api/v2/search): lack of logging if awaiting logRequestPromise took time (#4465)

Gergő Móricz582985891a8b
diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.ts
index e8892943f..8bb8074a3 100644
--- a/apps/api/src/controllers/v2/search.ts
+++ b/apps/api/src/controllers/v2/search.ts
@@ -301,7 +301,13 @@ export async function searchController(
// `searches` insert, to avoid a request_id FK violation. The insert has
// been in flight since the top of the controller, so this is ~free in
// practice; robustInsert never rejects, so this await cannot throw.
+ const logStart = Date.now();
await logRequestPromise;
+ const waited = Date.now() - logStart;
+ if (waited >= 5)
+ logger.warn("Had to wait for log request promise to complete", {
+ timeMs: waited,
+ });
logSearch(
{