mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
test(core): make websocket overflow fixture deterministic (#45586)
This commit is contained in:
committed by
GitHub
Unverified
parent
367cf59612
commit
2142de87dd
@@ -698,16 +698,22 @@ describe("SessionModelTransport", () => {
|
||||
|
||||
test("poisons instead of dropping data when the inbound queue overflows", async () => {
|
||||
const messages = queue<string | Uint8Array, AIError>()
|
||||
const poisoned = Deferred.makeUnsafe<void>()
|
||||
let closed = 0
|
||||
const connector: WebSocketConnector = {
|
||||
open: () =>
|
||||
Effect.succeed({
|
||||
sendText: () =>
|
||||
// Hold consumption at the send boundary until the reader fills and poisons the inbound queue.
|
||||
Effect.sync(() => {
|
||||
for (let index = 0; index <= 129; index++) Queue.offerUnsafe(messages, `frame:${index}`)
|
||||
}),
|
||||
messages: Stream.fromQueue(messages),
|
||||
close: Effect.sync(() => closed++).pipe(Effect.andThen(Queue.shutdown(messages)), Effect.asVoid),
|
||||
}).pipe(Effect.andThen(Deferred.await(poisoned))),
|
||||
messages: Stream.fromQueue(messages).pipe(Stream.tap(() => Effect.yieldNow)),
|
||||
close: Effect.sync(() => closed++).pipe(
|
||||
Effect.andThen(Deferred.succeed(poisoned, undefined)),
|
||||
Effect.andThen(Queue.shutdown(messages)),
|
||||
Effect.asVoid,
|
||||
),
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -721,7 +727,7 @@ describe("SessionModelTransport", () => {
|
||||
...item,
|
||||
driver: {
|
||||
create: item.driver.create,
|
||||
observe: (_create, frame) => Effect.sleep("1 millis").pipe(Effect.as({ type: "frame" as const, frame })),
|
||||
observe: (_create, frame) => Effect.succeed({ type: "frame" as const, frame }),
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user