(client, socket)
| 7107 | return result; |
| 7108 | } |
| 7109 | function connectH2(client, socket) { |
| 7110 | return __async(this, null, function* () { |
| 7111 | client[kSocket] = socket; |
| 7112 | if (!h2ExperimentalWarned) { |
| 7113 | h2ExperimentalWarned = true; |
| 7114 | process.emitWarning("H2 support is experimental, expect them to change at any time.", { |
| 7115 | code: "UNDICI-H2" |
| 7116 | }); |
| 7117 | } |
| 7118 | const session = http2.connect(client[kUrl], { |
| 7119 | createConnection: () => socket, |
| 7120 | peerMaxConcurrentStreams: client[kMaxConcurrentStreams] |
| 7121 | }); |
| 7122 | session[kOpenStreams] = 0; |
| 7123 | session[kClient] = client; |
| 7124 | session[kSocket] = socket; |
| 7125 | util.addListener(session, "error", onHttp2SessionError); |
| 7126 | util.addListener(session, "frameError", onHttp2FrameError); |
| 7127 | util.addListener(session, "end", onHttp2SessionEnd); |
| 7128 | util.addListener(session, "goaway", onHTTP2GoAway); |
| 7129 | util.addListener(session, "close", function() { |
| 7130 | const { [kClient]: client2 } = this; |
| 7131 | const { [kSocket]: socket2 } = client2; |
| 7132 | const err = this[kSocket][kError] || this[kError] || new SocketError("closed", util.getSocketInfo(socket2)); |
| 7133 | client2[kHTTP2Session] = null; |
| 7134 | if (client2.destroyed) { |
| 7135 | assert(client2[kPending] === 0); |
| 7136 | const requests = client2[kQueue].splice(client2[kRunningIdx]); |
| 7137 | for (let i = 0; i < requests.length; i++) { |
| 7138 | const request = requests[i]; |
| 7139 | util.errorRequest(client2, request, err); |
| 7140 | } |
| 7141 | } |
| 7142 | }); |
| 7143 | session.unref(); |
| 7144 | client[kHTTP2Session] = session; |
| 7145 | socket[kHTTP2Session] = session; |
| 7146 | util.addListener(socket, "error", function(err) { |
| 7147 | assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); |
| 7148 | this[kError] = err; |
| 7149 | this[kClient][kOnError](err); |
| 7150 | }); |
| 7151 | util.addListener(socket, "end", function() { |
| 7152 | util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this))); |
| 7153 | }); |
| 7154 | util.addListener(socket, "close", function() { |
| 7155 | const err = this[kError] || new SocketError("closed", util.getSocketInfo(this)); |
| 7156 | client[kSocket] = null; |
| 7157 | if (this[kHTTP2Session] != null) { |
| 7158 | this[kHTTP2Session].destroy(err); |
| 7159 | } |
| 7160 | client[kPendingIdx] = client[kRunningIdx]; |
| 7161 | assert(client[kRunning] === 0); |
| 7162 | client.emit("disconnect", client[kUrl], [client], err); |
| 7163 | client[kResume](); |
| 7164 | }); |
| 7165 | let closed = false; |
| 7166 | socket.on("close", () => { |
no test coverage detected