debug(gis-search): re-add minimal diagnostic for intermittent failures

Logs session + token + duration on every search. Will revert after
cause identified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude VM
2026-05-19 00:07:19 +03:00
parent 68355efbba
commit 3d389bf10a
+15 -7
View File
@@ -6,7 +6,12 @@ export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET(request: Request) {
const t0 = Date.now();
const session = await getAuthSession();
const hasTok = !!(session as { accessToken?: string } | null)?.accessToken;
const err = (session as { error?: string } | null)?.error;
console.log("[gis-search] in session=%s tok=%s err=%s", !!session, hasTok, err ?? "none");
if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
@@ -21,16 +26,19 @@ export async function GET(request: Request) {
}
try {
return NextResponse.json(await gisApi.search(q, limit));
} catch (err) {
if (err instanceof GisApiError) {
const data = await gisApi.search(q, limit);
console.log("[gis-search] ok q=%s dur=%dms", q, Date.now() - t0);
return NextResponse.json(data);
} catch (e) {
if (e instanceof GisApiError) {
console.log("[gis-search] gis-api %d %s", e.status, e.code);
return NextResponse.json(
{ error: err.code, status: err.status },
{ status: err.status },
{ error: e.code, status: e.status },
{ status: e.status },
);
}
const msg = err instanceof Error ? err.message : String(err);
console.error("[gis-search] internal error:", msg);
const msg = e instanceof Error ? e.message : String(e);
console.error("[gis-search] internal:", msg);
return NextResponse.json(
{ error: "internal_error", hint: msg.slice(0, 200) },
{ status: 500 },