@@ -28,7 +28,7 @@ import { McpAuth } from "./auth"
2828import { EventV2Bridge } from "@/event-v2-bridge"
2929import { TuiEvent } from "@/server/tui-event"
3030import open from "open"
31- import { Cause , Effect , Exit , Layer , Option , Context , Schema , Stream } from "effect"
31+ import { Cause , Effect , Exit , Layer , Context , Schema , Stream } from "effect"
3232import { EffectBridge } from "@/effect/bridge"
3333import { InstanceState } from "@/effect/instance-state"
3434import { ChildProcess , ChildProcessSpawner } from "effect/unstable/process"
@@ -928,16 +928,17 @@ export const layer = Layer.effect(
928928 const pending = pendingOAuthTransports . get ( mcpName )
929929 if ( ! pending ) throw new Error ( `No pending OAuth flow for MCP server: ${ mcpName } ` )
930930
931- const result = yield * Effect . tryPromise ( {
932- try : ( ) => pending . transport . finishAuth ( authorizationCode ) . then ( ( ) => true as const ) ,
933- catch : ( error ) => {
934- return error
935- } ,
936- } ) . pipe ( Effect . option )
931+ const error = yield * Effect . tryPromise ( {
932+ try : ( ) => pending . transport . finishAuth ( authorizationCode ) ,
933+ catch : ( error ) => error ,
934+ } ) . pipe (
935+ Effect . match ( {
936+ onFailure : ( error ) => ( error instanceof Error ? error . message : String ( error ) ) ,
937+ onSuccess : ( ) => undefined ,
938+ } ) ,
939+ )
937940
938- if ( Option . isNone ( result ) ) {
939- return { status : "failed" , error : "OAuth completion failed" } satisfies Status
940- }
941+ if ( error ) return { status : "failed" , error : `OAuth completion failed: ${ error } ` } satisfies Status
941942
942943 yield * Effect . promise ( ( ) => pending . provider ?. commit ( ) ?? Promise . resolve ( ) )
943944 yield * auth . clearCodeVerifier ( mcpName )
0 commit comments