Skip to content

Commit 0847de6

Browse files
authored
Merge branch 'master' into inlined.onCallGenkit
2 parents 57a0d29 + 01c1198 commit 0847de6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

spec/common/providers/https.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ describe("onCallHandler", () => {
778778

779779
const resp = await runHandler(fn, mockReq as any);
780780
const data = [`data: {"message":"hello"}`, `data: {"result":"world"}`];
781-
expect(resp.body).to.equal([...data, ""].join("\n"));
781+
expect(resp.body).to.equal([...data, ""].join("\n\n"));
782782
});
783783

784784
it("returns error in SSE format", async () => {
@@ -800,7 +800,7 @@ describe("onCallHandler", () => {
800800

801801
const resp = await runHandler(fn, mockReq as any);
802802
const data = [`data: {"error":{"message":"INTERNAL","status":"INTERNAL"}}`];
803-
expect(resp.body).to.equal([...data, ""].join("\n"));
803+
expect(resp.body).to.equal([...data, ""].join("\n\n"));
804804
});
805805

806806
it("always returns error for v1 callables", async () => {
@@ -851,7 +851,7 @@ describe("onCallHandler", () => {
851851

852852
const resp = await runHandler(fn, mockReq);
853853

854-
expect(resp.body).to.equal(`data: {"message":"initial message"}\n`);
854+
expect(resp.body).to.equal(`data: {"message":"initial message"}\n\n`);
855855
});
856856

857857
describe("Heartbeats", () => {
@@ -890,7 +890,7 @@ describe("onCallHandler", () => {
890890
await clock.tickAsync(11_000);
891891
const resp = await handlerPromise;
892892
const data = [": ping", ": ping", `data: {"result":"done"}`];
893-
expect(resp.body).to.equal([...data, ""].join("\n"));
893+
expect(resp.body).to.equal([...data, ""].join("\n\n"));
894894
});
895895

896896
it("doesn't send heartbeat messages if user writes data", async () => {
@@ -919,7 +919,7 @@ describe("onCallHandler", () => {
919919
await clock.tickAsync(10_000);
920920
const resp = await handlerPromise;
921921
const data = [`data: {"message":"hello"}`, `data: {"result":"done"}`];
922-
expect(resp.body).to.equal([...data, ""].join("\n"));
922+
expect(resp.body).to.equal([...data, ""].join("\n\n"));
923923
});
924924

925925
it("respects null heartbeatSeconds option", async () => {
@@ -945,7 +945,7 @@ describe("onCallHandler", () => {
945945
const handlerPromise = runHandler(fn, mockReq as any);
946946
await clock.tickAsync(31_000);
947947
const resp = await handlerPromise;
948-
expect(resp.body).to.equal('data: {"result":"done"}\n');
948+
expect(resp.body).to.equal('data: {"result":"done"}\n\n');
949949
});
950950
});
951951
});

src/common/providers/https.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export interface CallableRequest<T = any> {
123123
data: T;
124124

125125
/**
126-
* The result of decoding and verifying a Firebase AppCheck token.
126+
* The result of decoding and verifying a Firebase App Check token.
127127
*/
128128
app?: AppCheckData;
129129

@@ -145,15 +145,15 @@ export interface CallableRequest<T = any> {
145145
/**
146146
* Whether this is a streaming request.
147147
* Code can be optimized by not trying to generate a stream of chunks to
148-
* call response.sendChunk on if request.acceptsStreaming is false.
149-
* It is always safe, however, to call response.sendChunk as this will
150-
* noop if acceptsStreaming is false.
148+
* call `response.sendChunk` if `request.acceptsStreaming` is false.
149+
* It is always safe, however, to call `response.sendChunk` as this will
150+
* noop if `acceptsStreaming` is false.
151151
*/
152152
acceptsStreaming: boolean;
153153
}
154154

155155
/**
156-
* CallableProxyResponse allows streaming response chunks and listening to signals
156+
* `CallableProxyResponse` allows streaming response chunks and listening to signals
157157
* triggered in events such as a disconnect.
158158
*/
159159
export interface CallableResponse<T = unknown> {
@@ -166,7 +166,7 @@ export interface CallableResponse<T = unknown> {
166166
sendChunk: (chunk: T) => Promise<boolean>;
167167

168168
/**
169-
* An AbortSignal that is triggered when the client disconnects or the
169+
* An `AbortSignal` that is triggered when the client disconnects or the
170170
* request is terminated prematurely.
171171
*/
172172
signal: AbortSignal;
@@ -738,7 +738,7 @@ export function onCallHandler<Req = any, Res = any, Stream = unknown>(
738738
}
739739

740740
function encodeSSE(data: unknown): string {
741-
return `data: ${JSON.stringify(data)}\n`;
741+
return `data: ${JSON.stringify(data)}\n\n`;
742742
}
743743

744744
/** @internal */
@@ -766,7 +766,7 @@ function wrapOnCallHandler<Req = any, Res = any, Stream = unknown>(
766766
if (!abortController.signal.aborted) {
767767
heartbeatInterval = setTimeout(() => {
768768
if (!abortController.signal.aborted) {
769-
res.write(": ping\n");
769+
res.write(": ping\n\n");
770770
scheduleHeartbeat();
771771
}
772772
}, heartbeatSeconds * 1000);

0 commit comments

Comments
 (0)