Skip to content

Commit

Permalink
386th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Oct 14, 2024
1 parent d443894 commit dfc8c7e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/src/routes/sse/+handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default async (app: FastifyInstance) => {

req.raw.on('close', () => {
clearInterval(interval);
reply.sse({ event: 'close' });
});
});
};
8 changes: 5 additions & 3 deletions app/src/routes/sse/event/[id]/+handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export default (async (app) => {
(req, reply) => {
const { id } = req.params;

sseEmitter.on(`/sse/event/${id}`, (data) => {
function eventId(data?: string | object) {
reply.sse({ id, data });
});
}

sseEmitter.on(`/sse/event/${id}`, eventId);

req.raw.on('close', () => {
reply.sse({ event: 'close' });
sseEmitter.off(`/sse/event/${id}`, eventId);
});
},
);
Expand Down
1 change: 0 additions & 1 deletion app/src/routes/sse/model/+handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default (async (app) => {

request.raw.on('close', async () => {
await stream.cancel();
reply.sse({ event: 'close' });
});
},
);
Expand Down

0 comments on commit dfc8c7e

Please sign in to comment.