Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

Commit 9750748

Browse files
committed
fix(BufferedStream): handle socket errors by closing the stream
1 parent cf42f96 commit 9750748

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/BufferedStream.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ class BufferedStream<T extends Socket> implements Stream {
2020
}
2121
});
2222

23+
/* istanbul ignore next */
24+
socket.on('error', () => {
25+
if (this.readResolver) {
26+
this.readResolver[2](new StreamClosedError('Socket encountered an error'));
27+
}
28+
29+
this.closed = true;
30+
});
31+
2332
socket.on('close', () => {
2433
if (this.readResolver) {
2534
this.readResolver[2](new StreamClosedError('Socket was closed'));

0 commit comments

Comments
 (0)