mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 13:59:01 -05:00
support once listener
This commit is contained in:
parent
ee4c391886
commit
8ece841314
1 changed files with 5 additions and 3 deletions
|
@ -360,15 +360,17 @@ function _afterConnect(
|
|||
|
||||
socket._unrefTimer();
|
||||
|
||||
const connectListeners = socket.listenerCount("connect");
|
||||
const readyListeners = socket.listenerCount("ready");
|
||||
const dataListeners = socket.listenerCount("data");
|
||||
|
||||
socket.emit("connect");
|
||||
socket.emit("ready");
|
||||
|
||||
// Note: This is Deno specific logic
|
||||
// If there's no listener for the connect, ready, data event,
|
||||
// we delay the first read. This is necessary for http.request to work properly.
|
||||
const connectListeners = socket.listenerCount("connect");
|
||||
const readyListeners = socket.listenerCount("ready");
|
||||
const dataListeners = socket.listenerCount("data");
|
||||
// See https://github.com/denoland/deno/pull/25470#issuecomment-2435077722
|
||||
if (connectListeners === 0 && readyListeners === 0 && dataListeners === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue