| @@ -351,9 +351,11 @@ export const createMcpConnector = (input: ConnectorInput): McpConnector => { · 350 unmodified lines |
| 351 | 351 | // error), which used to misclassify an expired token as a generic |
| 352 | 352 | // connection failure. Propagate it as-is instead. |
| 353 | 353 | return connectStreamableHttp.pipe( |
| 354 | | − Effect.catch((error) => { |
| 355 | | − if (Predicate.isTagged(error, "McpOAuthReauthorizationRequired")) return Effect.fail(error); |
| 356 | | − if (error.httpStatus === 401 || error.httpStatus === 403) return Effect.fail(error); |
| 354 | + Effect.catch((failure) => { |
| 355 | + if (Predicate.isTagged(failure, "McpOAuthReauthorizationRequired")) { |
| 356 | + return Effect.fail(failure); |
| 357 | + } |
| 358 | + if (failure.httpStatus === 401 || failure.httpStatus === 403) return Effect.fail(failure); |
| 357 | 359 | // When the fallback ALSO fails, the streamable-http failure is the |
| 358 | 360 | // interesting one: most modern servers don't serve legacy SSE at all |
| 359 | 361 | // (GET → 405), so reporting only "Failed connecting via sse" points |
| @@ -362,16 +364,16 @@ export const createMcpConnector = (input: ConnectorInput): McpConnector => { · 2 unmodified lines |
| 362 | 364 | return connectSse.pipe( |
| 363 | 365 | Effect.catch( |
| 364 | 366 | ( |
| 365 | | − sseError, |
| 367 | + sseFailure, |
| 366 | 368 | ): Effect.Effect<never, McpConnectionError | McpOAuthReauthorizationRequired> => { |
| 367 | | − if (Predicate.isTagged(sseError, "McpOAuthReauthorizationRequired")) { |
| 368 | | − return Effect.fail(sseError); |
| 369 | + if (Predicate.isTagged(sseFailure, "McpOAuthReauthorizationRequired")) { |
| 370 | + return Effect.fail(sseFailure); |
| 369 | 371 | } |
| 370 | 372 | return Effect.fail( |
| 371 | 373 | new McpConnectionError({ |
| 372 | 374 | transport: "streamable-http", |
| 373 | | − message: `${error.message}; SSE fallback also failed: ${sseError.message}`, |
| 374 | | − ...(error.httpStatus === undefined ? {} : { httpStatus: error.httpStatus }), |
| 375 | + message: `${failure.message}; SSE fallback also failed: ${sseFailure.message}`, |
| 376 | + ...(failure.httpStatus === undefined ? {} : { httpStatus: failure.httpStatus }), |
| 375 | 377 | }), |
| 376 | 378 | ); |
| 377 | 379 | }, |