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