diff --git a/apps/server/src/auth/http.ts b/apps/server/src/auth/http.ts index 80352b6f53..c539bb52b0 100644 --- a/apps/server/src/auth/http.ts +++ b/apps/server/src/auth/http.ts @@ -272,7 +272,12 @@ export const layer = HttpApiBuilder.group( function* (args) { yield* annotateEnvironmentRequest(args.endpoint.name); const request = yield* HttpServerRequest.HttpServerRequest; - const result = yield* serverAuth.getSessionState(request); + const reproStart = Date.now(); + console.log(`[repro-24221] /api/auth/session START ${new Date(reproStart).toISOString()}`); + const result = yield* serverAuth.getSessionState(request).pipe( + Effect.onInterrupt(() => Effect.sync(() => console.log(`[repro-24221] /api/auth/session INTERRUPTED after ${Date.now() - reproStart}ms`))), + ); + console.log(`[repro-24221] /api/auth/session END after ${Date.now() - reproStart}ms authenticated=${result.authenticated}`); const credential = EnvironmentAuth.selectRequestCredential( request, sessions.cookieName, diff --git a/apps/server/src/persistence/AuthSessions.ts b/apps/server/src/persistence/AuthSessions.ts index a907b04df7..657ae3b9ec 100644 --- a/apps/server/src/persistence/AuthSessions.ts +++ b/apps/server/src/persistence/AuthSessions.ts @@ -1,3 +1,5 @@ +import { createRequire } from "node:module"; +const require = createRequire(import.meta.url); import * as Context from "effect/Context"; import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient"; import * as Effect from "effect/Effect"; @@ -416,7 +418,12 @@ export const make = Effect.gen(function* () { ); const getById: AuthSessionRepository["Service"]["getById"] = (input) => - getSessionRowById(input).pipe( + Effect.suspend(() => { + let ms = 0; + try { ms = Number(require("node:fs").readFileSync("/tmp/issue-lead-24221-r3/delay_ms", "utf8").trim()) || 0; } catch {} + console.log(`[repro-24221] getById ${new Date().toISOString()} delay=${ms}`); + return Effect.sleep(ms); + }).pipe(Effect.andThen(getSessionRowById(input))).pipe( NodeSqliteClient.readOnly, Effect.mapError( toPersistenceSqlOrDecodeError(