Skip to content

Commit 4753cb1

Browse files
committed
fix: fix sse connection logging
1 parent eb16c22 commit 4753cb1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/browser/sse.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,23 @@ class ServerSentEventHandler<
100100

101101
return super.predicate(args)
102102
}
103+
104+
async log(args: { request: Request; response: Response }): Promise<void> {
105+
super.log({
106+
request: args.request,
107+
108+
/**
109+
* @note Construct a placeholder response since SSE response
110+
* is being streamed and cannot be cloned/consumed at this point.
111+
* This also allows us to rely on the same logging logic as in HTTP handlers.
112+
*/
113+
response: new Response('[streaming]', {
114+
status: args.response.status,
115+
statusText: args.response.statusText,
116+
headers: args.response.headers,
117+
}),
118+
})
119+
}
103120
}
104121

105122
type Values<T> = T[keyof T]

test/browser/sse-api/sse.server.connect.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ test('makes the actual request when called "server.connect()"', async ({
4141

4242
return new Response(stream, {
4343
headers: {
44+
'access-control-allow-origin': '*',
4445
'content-type': 'text/event-stream',
4546
'cache-control': 'no-cache',
4647
connection: 'keep-alive',

0 commit comments

Comments
 (0)