Skip to content

Commit 753ada8

Browse files
authored
fix: SSE destroy not triggering error event and causing process exit, close #120 (#122)
1 parent 5ade4a8 commit 753ada8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plugin/src/core/sse.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ class SSEStream extends Transform {
7272
write(message: SSEMessage, ...args: any[]): boolean {
7373
return super.write(message, ...args)
7474
}
75+
76+
destroy(error?: Error): this {
77+
if (error) {
78+
this.write({ event: 'error', data: error.message })
79+
}
80+
this.end()
81+
return this
82+
}
7583
}
7684

7785
function dataString(data: string | object): string {

0 commit comments

Comments
 (0)