Skip to content

Commit 69ff8ab

Browse files
committed
test(phase-c): move Test A polling into Effect, drop nested runPromise
Addresses Copilot PR review (partial). Keeps `fiber.pollUnsafe()` — it is public API and the correct synchronous peek for early-exit detection — but lifts the poll loop out of `Effect.promise` and into `Effect.gen` so the `sessionStatus.get` call no longer needs a nested `Effect.runPromise`. Copilot's suggested `Effect.raceFirst(Effect.fnUntraced(...), ...)` snippet does not typecheck (`fnUntraced` returns a function, not an Effect), so the literal suggestion was not applied.
1 parent 6254b3b commit 69ff8ab

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

packages/opencode/test/session/subagent-hang-regression.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,23 @@ it.live(
250250
// Bounded wait for the retry transition. Budget covers: first
251251
// setup pass (cold provider state, models.dev load), one chunk
252252
// timeout (1s), plus schedule classification. If the fiber never
253-
// transitions to retry, the hang regression is back.
254-
const observed = yield* Effect.promise(async () => {
253+
// transitions to retry, the hang regression is back. `pollUnsafe` is
254+
// the public synchronous-peek API — we use it to short-circuit if
255+
// the fiber dies early so the error cause surfaces, rather than
256+
// timing out blindly at 8s.
257+
const observed = yield* Effect.gen(function* () {
255258
const end = Date.now() + 8_000
256259
while (Date.now() < end) {
257260
const exit = fiber.pollUnsafe()
258-
if (exit) {
259-
throw new Error(`loop exited before retry observed: ${JSON.stringify(exit)}`)
260-
}
261-
const snap = await Effect.runPromise(sessionStatus.get(chat.id))
261+
if (exit) return yield* Effect.fail(new Error(`loop exited before retry observed: ${JSON.stringify(exit)}`))
262+
const snap = yield* sessionStatus.get(chat.id)
262263
if (snap.type === "retry") return snap
263-
await new Promise((done) => setTimeout(done, 25))
264+
yield* Effect.sleep("25 millis")
264265
}
265-
const snap = await Effect.runPromise(sessionStatus.get(chat.id))
266-
throw new Error(`expected retry status within 8s; last status: ${JSON.stringify(snap)}`)
266+
const snap = yield* sessionStatus.get(chat.id)
267+
return yield* Effect.fail(
268+
new Error(`expected retry status within 8s; last status: ${JSON.stringify(snap)}`),
269+
)
267270
})
268271

269272
expect(observed.type).toBe("retry")

0 commit comments

Comments
 (0)