Skip to content

Commit c4e4a83

Browse files
Copilotsonnyp
andcommitted
Fix: Prevent 'write after end' error in connection when socket is detached
Co-authored-by: sonnyp <[email protected]>
1 parent bed30bc commit c4e4a83

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/connection/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ class Connection extends EventEmitter {
328328
throw new Error("Connection is closing");
329329
}
330330

331+
if (!this.socket) {
332+
throw new Error("Socket is not connected");
333+
}
334+
331335
return new Promise((resolve, reject) => {
332336
this.socket.write(string, (err) => (err ? reject(err) : resolve()));
333337
});

0 commit comments

Comments
 (0)