1
0
Fork 0
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:
Yoshiya Hinosawa 2024-10-25 01:12:59 +09:00
parent ee4c391886
commit 8ece841314
No known key found for this signature in database
GPG key ID: 9017DB4559488785

View file

@ -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;
}