fix: address Copilot review round 5 on #2318
RemoteClientTransport keeps its open-stream bookkeeping whether or not the consumer logs requests, so onFetchStreamUpdate works on its own and close() can synthesize the terminal update. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01APKSYHGxXBUpnR7ErFiLJn Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
abc4967298
commit
a38f1322c1
1 changed files with 37 additions and 5 deletions
|
|
@ -432,6 +432,38 @@ describe("RemoteClientTransport (focused branch coverage)", () => {
|
|||
expect(onFetchStreamUpdate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("synthesizes the close on close() for a consumer that registered only onFetchStreamUpdate", async () => {
|
||||
const onFetchStreamUpdate = vi.fn();
|
||||
const { response, push } = createPushableEventStream();
|
||||
const t = makeTransport(
|
||||
{ events: () => response },
|
||||
{ onFetchStreamUpdate },
|
||||
);
|
||||
await t.start();
|
||||
push({
|
||||
type: "fetch_request",
|
||||
data: {
|
||||
id: "stream",
|
||||
method: "GET",
|
||||
url: "http://x/mcp",
|
||||
timestamp: new Date().toISOString(),
|
||||
requestHeaders: {},
|
||||
responseStatus: 200,
|
||||
responseHeaders: { "content-type": "text/event-stream" },
|
||||
} as never,
|
||||
});
|
||||
push({
|
||||
type: "fetch_stream_update",
|
||||
data: { id: "stream", eventCount: 3 },
|
||||
});
|
||||
await tick();
|
||||
await t.close();
|
||||
expect(onFetchStreamUpdate).toHaveBeenLastCalledWith("stream", {
|
||||
eventCount: 3,
|
||||
closedAt: expect.any(Date),
|
||||
});
|
||||
});
|
||||
|
||||
it("drops fetch_stream_update events when no handler is registered", async () => {
|
||||
const onFetchRequest = vi.fn();
|
||||
const t = makeTransport(
|
||||
|
|
|
|||
Loading…
Reference in a new issue