From 92db5e1024590de10dbf95232d810c4b0686cd15 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Tue, 27 Oct 2026 14:55:57 -0500 Subject: [PATCH] chore(core): log cancelled and expired oauth attempts (#59689) --- packages/core/src/integration.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/core/src/integration.ts b/packages/core/src/integration.ts index 8b98e9ce89e..824d2975abd 100644 --- a/packages/core/src/integration.ts +++ b/packages/core/src/integration.ts @@ -550,10 +550,10 @@ const layer = Layer.effect( const now = yield* Clock.currentTimeMillis const expired = yield* SynchronizedRef.modify(attempts, (current) => { const next = new Map(current) - const scopes: Scope.Closeable[] = [] + const closed: { attemptID: AttemptID; integrationID: ID; scope: Scope.Closeable }[] = [] for (const [id, attempt] of current) { if (attempt.status === "pending" && !attempt.persisting && attempt.time.expires <= now) { - scopes.push(attempt.scope) + closed.push({ attemptID: id, integrationID: attempt.integrationID, scope: attempt.scope }) next.set(id, { status: "expired", integrationID: attempt.integrationID, @@ -564,9 +564,18 @@ const layer = Layer.effect( } if (attempt.status !== "pending" && attempt.removeAt <= now) next.delete(id) } - return [scopes, next] + return [closed, next] }) - yield* Effect.forEach(expired, close, { discard: true }) + yield* Effect.forEach( + expired, + (attempt) => + Effect.logInfo("integration oauth attempt closed", { + integrationID: attempt.integrationID, + attemptID: attempt.attemptID, + reason: "expired", + }).pipe(Effect.andThen(close(attempt.scope))), + { discard: true }, + ) }) const scrubCommands = Effect.fnUntraced(function* () { @@ -867,7 +876,13 @@ const layer = Layer.effect( next.delete(input.attemptID) return [match, next] }) - if (attempt) yield* Scope.close(attempt.scope, Exit.void) + if (!attempt) return + yield* Effect.logInfo("integration oauth attempt closed", { + integrationID: input.integrationID, + attemptID: input.attemptID, + reason: "cancelled", + }) + yield* Scope.close(attempt.scope, Exit.void) }), }, command: {