Skip to content

Commit dfe8f2e

Browse files
only21milclaude
andcommitted
test(server): task_cancel integration watches start from a fixed cursor
After merging main, the shell-command cases timed out waiting for the background roster event. The watch forked a live-tail subscriber that read its starting sequence after the provider events were already committed, so it never saw them. Read the cursor before forking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0daef1f commit dfe8f2e

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎apps/server/src/mcp/TaskCancelNativeSubagent.integration.test.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,21 @@ const cancelBackgroundOnlyTask = (
198198
const orchestrator = yield* Orchestrator.OrchestratorV2;
199199
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
200200
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
201+
const eventSink = yield* EventSink.EventSinkV2;
201202
const parentThreadId = ThreadId.make("thread:task-cancel-parent");
203+
// Read the cursor before forking: provider events offered right after a watch can
204+
// commit before a live-tail subscriber has read its starting sequence.
202205
const watch = (predicate: (event: OrchestrationV2DomainEvent) => boolean) =>
203-
orchestrator.streamDomainEvents.pipe(
204-
Stream.filter(predicate),
205-
Stream.take(1),
206-
Stream.runDrain,
207-
Effect.forkScoped,
206+
eventSink.latestSequence().pipe(
207+
Effect.flatMap((afterSequence) =>
208+
eventSink.stream({ afterSequence }).pipe(
209+
Stream.map((stored) => stored.event),
210+
Stream.filter(predicate),
211+
Stream.take(1),
212+
Stream.runDrain,
213+
Effect.forkScoped,
214+
),
215+
),
208216
);
209217
const turnRunning = () =>
210218
watch(

0 commit comments

Comments
 (0)