Skip to content

Commit

Permalink
Fixed the issue that the socket is closed too early (kylefarris#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihui committed Jul 16, 2024
1 parent 17b05e7 commit adc8bdb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,9 +2273,6 @@ class NodeClam {
.on('end', () => {
if (this.settings.debugMode) console.log(`${this.debugLabel}: The input stream has dried up.`);
finished = true;
stream.destroy();
socket.destroy();
transform.destroy();
})
// There was an error with the stream (ex. uploader closed browser)
.on('error', (err) => {
Expand Down Expand Up @@ -2318,6 +2315,9 @@ class NodeClam {
if (this.settings.debugMode) console.log(`${this.debugLabel}: ClamAV is done scanning.`);
// Fully close up the socket
socket.end();
stream.destroy();
socket.destroy();
transform.destroy();

// Concat all the response chunks into a single buffer
const response = Buffer.concat(chunks);
Expand Down

0 comments on commit adc8bdb

Please sign in to comment.