Skip to content

Commit

Permalink
next tick
Browse files Browse the repository at this point in the history
  • Loading branch information
cirospaciari committed Aug 19, 2024
1 parent 5079d8a commit 9fd8872
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/node/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,11 @@ const Socket = (function (InternalSocket) {
const socket = this[bunSocketInternal];
if (socket) {
this[bunSocketInternal] = null;
socket.end();
// we still have a socket, call end before destroy
process.nextTick(endNT, socket, callback, err);
return;
}
// no socket, just destroy
process.nextTick(closeNT, callback, err);
}

Expand All @@ -657,6 +660,7 @@ const Socket = (function (InternalSocket) {
this.#final_callback = callback;
} else {
// emit FIN not allowing half open
this[bunSocketInternal] = null;
process.nextTick(endNT, socket, callback);
}
}
Expand Down

0 comments on commit 9fd8872

Please sign in to comment.