Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opencode/src/dag/runtime/recovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function reconcileWorkflow(
// never revisit it if the workflow is about to become terminal.
if (node.status === "pending" || node.status === "queued") {
if (node.childSessionId && cancelSession) {
yield* cancelSession(node.childSessionId).pipe(Effect.catch(() => Effect.void))
yield* cancelSession(node.childSessionId)
}
continue
}
Expand Down
18 changes: 18 additions & 0 deletions packages/opencode/test/dag/dag-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ describe("reconcileWorkflow", () => {
expect(result).toEqual({ reconciled: 0, ownershipLost: 0 })
})

it("aborts recovery when a stale restart-orphan session cannot be cancelled", async () => {
const events: TrackedEvent[] = []
const nodes = [makeNodeRow({ id: "n1", status: "queued", childSessionId: "ses_stale" })]
const dagLayer = makeDagLayer(nodes, events)
const checkStatus = () => Effect.succeed("active" as const)
const cancelSession = () => Effect.fail(new Error("cancel unavailable"))

const exit = await Effect.runPromise(
reconcileWorkflow("wf-1", checkStatus, cancelSession).pipe(
Effect.provide(dagLayer),
Effect.exit,
),
)

expect(Exit.isFailure(exit)).toBe(true)
expect(events).toEqual([])
})

it("cancels and fails a zero-message child classified as unknown exactly once", async () => {
const events: TrackedEvent[] = []
const cancelled: string[] = []
Expand Down
Loading