mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(core): stop MCP servers in parallel on shutdown (#58351)
This commit is contained in:
committed by
GitHub
Unverified
parent
09399e3eec
commit
7b14ad4be0
@@ -181,6 +181,9 @@ export const layer = (options?: Options) =>
|
||||
const credentials = yield* Credential.Service
|
||||
const root = yield* Effect.scope
|
||||
const fork = yield* FiberSet.makeRuntime<never, void, never>()
|
||||
// Server scopes close in parallel on shutdown, so one slow server's stop grace does not delay
|
||||
// the rest past a service restart's kill deadline and leave them orphaned.
|
||||
const servers = yield* Scope.fork(root, "parallel")
|
||||
|
||||
const entries = new Map<ServerName, ServerEntry>()
|
||||
const attached = new Map<ServerName, AttachedEntry[]>()
|
||||
@@ -451,7 +454,7 @@ export const layer = (options?: Options) =>
|
||||
// disabled/failed status for the duration of the connection attempt.
|
||||
entry.status = { status: "pending" }
|
||||
yield* bus.publish(McpEvent.StatusChanged, { server: name })
|
||||
const scope = yield* Scope.fork(root)
|
||||
const scope = yield* Scope.fork(servers)
|
||||
entry.scope = scope
|
||||
const authProvider = yield* connectProvider(entry)
|
||||
const { McpClient } = yield* Effect.promise(() => import("./client.js"))
|
||||
|
||||
Reference in New Issue
Block a user