From 9cdf8d9c2dc32121e5026af5224741d0f3bdb1d7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 16 Oct 2019 19:57:00 +0200 Subject: [PATCH] quic: allow `.connect()` when socket is already bound --- lib/internal/quic/core.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/internal/quic/core.js b/lib/internal/quic/core.js index 344deae3d6..640cac886a 100644 --- a/lib/internal/quic/core.js +++ b/lib/internal/quic/core.js @@ -910,13 +910,18 @@ class QuicSocket extends EventEmitter { if (typeof callback === 'function') session.on('ready', callback); - this[kMaybeBind]( - connectAfterBind.bind( - this, - session, - this.#lookup, - address, - getSocketType(type))); + const afterBind = + connectAfterBind.bind( + this, + session, + this.#lookup, + address, + getSocketType(type)); + if (this.#state === kSocketBound) { + afterBind(); + } else { + this[kMaybeBind](afterBind); + } return session; }