( sessionId: string | null, handle: string, close: (() => Promise<void>) | undefined, )
| 168 | * nothing can see, so name the handle and the session in a warning. |
| 169 | */ |
| 170 | const ignoreClose = ( |
| 171 | sessionId: string | null, |
| 172 | handle: string, |
| 173 | close: (() => Promise<void>) | undefined, |
| 174 | ): Promise<void> => { |
| 175 | if (!close) return Promise.resolve(); |
| 176 | const warn = (detail: unknown): Effect.Effect<void> => |
| 177 | Effect.sync(() => { |
| 178 | console.warn( |
| 179 | `[mcp] failed to close ${handle} for session ${sessionId ?? "<uninitialized>"}:`, |
| 180 | formatBoundaryError(detail), |
| 181 | ); |
| 182 | }); |
| 183 | return Effect.runPromise( |
| 184 | Effect.tryPromise({ try: close, catch: (cause) => new McpHandleCloseError({ cause }) }).pipe( |
| 185 | Effect.catch((error) => warn(error.cause)), |
| 186 | // A defect cannot escape either: this runs detached from any request. |
| 187 | Effect.catchCause((cause) => warn(Cause.squash(cause))), |
| 188 | ), |
| 189 | ); |
| 190 | }; |
| 191 | |
| 192 | // The store's error bodies are INNER responses (no CORS): the serving envelope |
| 193 | // re-wraps the store `Response` with CORS before it leaves the origin, so the |
no test coverage detected