mirror of
https://github.com/denoland/deno.git
synced 2025-01-07 22:58:24 -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();
|
socket._unrefTimer();
|
||||||
|
|
||||||
|
const connectListeners = socket.listenerCount("connect");
|
||||||
|
const readyListeners = socket.listenerCount("ready");
|
||||||
|
const dataListeners = socket.listenerCount("data");
|
||||||
|
|
||||||
socket.emit("connect");
|
socket.emit("connect");
|
||||||
socket.emit("ready");
|
socket.emit("ready");
|
||||||
|
|
||||||
// Note: This is Deno specific logic
|
// Note: This is Deno specific logic
|
||||||
// If there's no listener for the connect, ready, data event,
|
// 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.
|
// we delay the first read. This is necessary for http.request to work properly.
|
||||||
const connectListeners = socket.listenerCount("connect");
|
// See https://github.com/denoland/deno/pull/25470#issuecomment-2435077722
|
||||||
const readyListeners = socket.listenerCount("ready");
|
|
||||||
const dataListeners = socket.listenerCount("data");
|
|
||||||
if (connectListeners === 0 && readyListeners === 0 && dataListeners === 0) {
|
if (connectListeners === 0 && readyListeners === 0 && dataListeners === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue