Skip to content

Commit b5cc835

Browse files
authored
fix(browser): prevent error stream.push() after EOF (#1915)
Fixes #1914
1 parent 053a7be commit b5cc835

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib/BufferedDuplex.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export class BufferedDuplex extends Duplex {
5656
this.isSocketOpen = false
5757

5858
this.proxy.on('data', (chunk) => {
59-
this.push(chunk)
59+
if (!this.destroyed) {
60+
this.push(chunk)
61+
}
6062
})
6163
}
6264

src/lib/connect/ws.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ const browserStreamBuilder: StreamBuilder = (client, opts) => {
260260
let { data } = event
261261
if (data instanceof ArrayBuffer) data = Buffer.from(data)
262262
else data = Buffer.from(data as string, 'utf8')
263-
proxy.push(data)
263+
if (!proxy?.destroyed) {
264+
proxy.push(data)
265+
}
264266
}
265267

266268
function socketWriteBrowser(

0 commit comments

Comments
 (0)