MCPcopy
hub / github.com/anomalyco/opencode / hangUntilAborted

Function hangUntilAborted

packages/opencode/test/session/prompt.test.ts:1974–1988  ·  view source on GitHub ↗
(tool: { execute: (...args: any[]) => any })

Source from the content-addressed store, hash-verified

1972// Abort signal propagation tests for inline tool execution
1973
1974function hangUntilAborted(tool: { execute: (...args: any[]) => any }) {
1975 return Effect.gen(function* () {
1976 const ready = yield* Deferred.make<void>()
1977 const aborted = yield* Deferred.make<void>()
1978 const original = tool.execute
1979 tool.execute = (_args: any, ctx: any) => {
1980 ctx.abort.addEventListener("abort", () => succeedVoid(aborted), { once: true })
1981 if (ctx.abort.aborted) succeedVoid(aborted)
1982 succeedVoid(ready)
1983 return Effect.callback<never>(() => Effect.sync(() => succeedVoid(aborted)))
1984 }
1985 const restore = Effect.addFinalizer(() => Effect.sync(() => void (tool.execute = original)))
1986 return { ready, aborted, restore }
1987 })
1988}
1989
1990noLLMServer.instance(
1991 "interrupt propagates abort signal to read tool via file part (text/plain)",

Callers 1

prompt.test.tsFile · 0.85

Calls 5

succeedVoidFunction · 0.85
addEventListenerMethod · 0.80
syncMethod · 0.80
makeMethod · 0.45
callbackMethod · 0.45

Tested by

no test coverage detected