From a58ca7808ccde6ddd6dd2872ea8e177e62799adf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 08:55:04 +0000 Subject: [PATCH 1/2] Bump @grpc/grpc-js from 1.14.4 to 1.14.5 Bumps [@grpc/grpc-js](https://github.com/grpc/grpc-node) from 1.14.4 to 1.14.5. - [Release notes](https://github.com/grpc/grpc-node/releases) - [Commits](https://github.com/grpc/grpc-node/compare/@grpc/grpc-js@1.14.4...@grpc/grpc-js@1.14.5) --- updated-dependencies: - dependency-name: "@grpc/grpc-js" dependency-version: 1.14.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00b6e1795..2650ca402 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1359,9 +1359,10 @@ "dev": true }, "node_modules/@grpc/grpc-js": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.4.tgz", - "integrity": "sha512-k9Dj3DV/itK9D06Y8f190Qgop7/Ui+D0njFV3LHMPwPT75DpXLQohE9Wmz0QElrJnzsjB7KPWiKJbOl7IPDArQ==", + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.5.tgz", + "integrity": "sha512-7VZM+SVdEcUUqSQeNI3zM8Qs/BhQKZndPo2h5VkYkAM8Iz0wJIa8mKV5ekQGqG8UUsnkQ0NMxIxwkIHYvj0qOw==", + "license": "Apache-2.0", "dependencies": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" @@ -12694,9 +12695,9 @@ "dev": true }, "@grpc/grpc-js": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.4.tgz", - "integrity": "sha512-k9Dj3DV/itK9D06Y8f190Qgop7/Ui+D0njFV3LHMPwPT75DpXLQohE9Wmz0QElrJnzsjB7KPWiKJbOl7IPDArQ==", + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.5.tgz", + "integrity": "sha512-7VZM+SVdEcUUqSQeNI3zM8Qs/BhQKZndPo2h5VkYkAM8Iz0wJIa8mKV5ekQGqG8UUsnkQ0NMxIxwkIHYvj0qOw==", "requires": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" From b3b2f0dbb4130a09926f70d756151327b60b0fc3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 08:55:51 +0000 Subject: [PATCH 2/2] [dependabot skip] Update dist/ with build changes --- dist/cleanup.js | 504 ++++++++++++++++++++++++++++++++++++------------ dist/main.js | 504 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 754 insertions(+), 254 deletions(-) diff --git a/dist/cleanup.js b/dist/cleanup.js index fd0093705..b2c01c428 100644 --- a/dist/cleanup.js +++ b/dist/cleanup.js @@ -47536,7 +47536,7 @@ var require_package2 = __commonJS({ "node_modules/@grpc/grpc-js/package.json"(exports2, module2) { module2.exports = { name: "@grpc/grpc-js", - version: "1.14.4", + version: "1.14.5", description: "gRPC Library for Node - pure JS implementation", homepage: "https://grpc.io/", repository: "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", @@ -47709,6 +47709,9 @@ var require_logging = __commonJS({ var enabledTracers = /* @__PURE__ */ new Set(); var disabledTracers = /* @__PURE__ */ new Set(); for (const tracerName of tracersString.split(",")) { + if (tracerName.length === 0) { + continue; + } if (tracerName.startsWith("-")) { disabledTracers.add(tracerName.substring(1)); } else { @@ -47716,12 +47719,16 @@ var require_logging = __commonJS({ } } var allEnabled = enabledTracers.has("all"); + var anyTracerEnabled = allEnabled || enabledTracers.size > 0; function trace(severity, tracer, text) { if (isTracerEnabled(tracer)) { (0, exports2.log)(severity, (/* @__PURE__ */ new Date()).toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " + text); } } function isTracerEnabled(tracer) { + if (!anyTracerEnabled) { + return false; + } return !disabledTracers.has(tracer) && (allEnabled || enabledTracers.has(tracer)); } } @@ -49247,7 +49254,9 @@ var require_backoff_timeout = __commonJS({ this.maxDelay = options.maxDelay; } } - this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay); + if (this.traceEnabled) { + this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay); + } this.nextDelay = this.initialDelay; this.timerId = setTimeout(() => { }, 0); @@ -49256,12 +49265,19 @@ var require_backoff_timeout = __commonJS({ static getNextId() { return this.nextId++; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text); + } } runTimer(delay) { var _a, _b; - this.trace("runTimer(delay=" + delay + ")"); + if (this.traceEnabled) { + this.trace("runTimer(delay=" + delay + ")"); + } this.endTime = this.startTime; this.endTime.setMilliseconds(this.endTime.getMilliseconds() + delay); clearTimeout(this.timerId); @@ -49300,7 +49316,9 @@ var require_backoff_timeout = __commonJS({ * retroactively apply that reset to the current timer. */ reset() { - this.trace("reset() running=" + this.running); + if (this.traceEnabled) { + this.trace("reset() running=" + this.running); + } this.nextDelay = this.initialDelay; if (this.running) { const now = /* @__PURE__ */ new Date(); @@ -62562,7 +62580,7 @@ var require_single_subchannel_channel = __commonJS({ } } }; - this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener); + this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener, this.callNumber); if (this.readPending) { this.childCall.startRead(); } @@ -62732,7 +62750,9 @@ var require_subchannel = __commonJS({ } this.channelzRef = (0, channelz_1.registerChannelzSubchannel)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled); this.channelzTrace.addTrace("CT_INFO", "Subchannel created"); - this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2)); + if (this.traceEnabled) { + this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2)); + } this.secureConnector = credentials._createSecureConnector(channelTarget, options); } getChannelzInfo() { @@ -62744,11 +62764,21 @@ var require_subchannel = __commonJS({ target: this.subchannelAddressString }; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } + get refTraceEnabled() { + return logging.isTracerEnabled("subchannel_refcount"); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } refTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.refTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } handleBackoffTimer() { if (this.continueConnecting) { @@ -62805,10 +62835,12 @@ var require_subchannel = __commonJS({ if (oldStates.indexOf(this.connectivityState) === -1) { return false; } - if (errorMessage) { - this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"'); - } else { - this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]); + if (this.traceEnabled) { + if (errorMessage) { + this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"'); + } else { + this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]); + } } if (this.channelzEnabled) { this.channelzTrace.addTrace("CT_INFO", "Connectivity state change to " + connectivity_state_1.ConnectivityState[newState]); @@ -62852,11 +62884,15 @@ var require_subchannel = __commonJS({ return true; } ref() { - this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1)); + if (this.refTraceEnabled) { + this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1)); + } this.refcount += 1; } unref() { - this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1)); + if (this.refTraceEnabled) { + this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1)); + } this.refcount -= 1; if (this.refcount === 0) { this.channelzTrace.addTrace("CT_INFO", "Shutting down"); @@ -62874,7 +62910,7 @@ var require_subchannel = __commonJS({ } return false; } - createCall(metadata, host, method, listener) { + createCall(metadata, host, method, listener, callId) { if (!this.transport) { throw new Error("Cannot create call, subchannel not READY"); } @@ -62894,7 +62930,7 @@ var require_subchannel = __commonJS({ } else { statsTracker = {}; } - return this.transport.createCall(metadata, host, method, listener, statsTracker); + return this.transport.createCall(metadata, host, method, listener, statsTracker, callId); } /** * If the subchannel is currently IDLE, start connecting and switch to the @@ -63000,9 +63036,11 @@ var require_environment = __commonJS({ "node_modules/@grpc/grpc-js/build/src/environment.js"(exports2) { "use strict"; var _a; + var _b; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = void 0; + exports2.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = void 0; exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = ((_a = process.env.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) !== null && _a !== void 0 ? _a : "false") === "true"; + exports2.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = ((_b = process.env.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) !== null && _b !== void 0 ? _b : "false") === "true"; } }); @@ -63673,11 +63711,13 @@ var require_subchannel_call = __commonJS({ const maxReceiveMessageLength = (_a = transport.getOptions()["grpc.max_receive_message_length"]) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH; this.decoder = new stream_decoder_1.StreamDecoder(maxReceiveMessageLength); http2Stream.on("response", (headers, flags) => { - let headersString = ""; - for (const header of Object.keys(headers)) { - headersString += " " + header + ": " + headers[header] + "\n"; + if (this.traceEnabled) { + let headersString = ""; + for (const header of Object.keys(headers)) { + headersString += " " + header + ": " + headers[header] + "\n"; + } + this.trace("Received server headers:\n" + headersString); } - this.trace("Received server headers:\n" + headersString); this.httpStatusCode = headers[":status"]; if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) { this.handleTrailers(headers); @@ -63703,7 +63743,9 @@ var require_subchannel_call = __commonJS({ if (this.statusOutput) { return; } - this.trace("receive HTTP/2 data frame of length " + data.length); + if (this.traceEnabled) { + this.trace("receive HTTP/2 data frame of length " + data.length); + } let messages; try { messages = this.decoder.write(data); @@ -63717,7 +63759,9 @@ var require_subchannel_call = __commonJS({ return; } for (const message of messages) { - this.trace("parsed message of length " + message.length); + if (this.traceEnabled) { + this.trace("parsed message of length " + message.length); + } this.callEventTracker.addMessageReceived(); this.tryPush(message); } @@ -63730,7 +63774,9 @@ var require_subchannel_call = __commonJS({ this.serverEndedCall = true; process.nextTick(() => { var _a2; - this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode); + if (this.traceEnabled) { + this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode); + } if (((_a2 = this.finalStatus) === null || _a2 === void 0 ? void 0 : _a2.code) === constants_1.Status.OK) { return; } @@ -63798,7 +63844,9 @@ var require_subchannel_call = __commonJS({ }); http2Stream.on("error", (err) => { if (err.code !== "ERR_HTTP2_STREAM_ERROR") { - this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall); + if (this.traceEnabled) { + this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall); + } this.internalError = err; } this.callEventTracker.onStreamEnd(false); @@ -63820,7 +63868,9 @@ var require_subchannel_call = __commonJS({ outputStatus() { if (!this.statusOutput) { this.statusOutput = true; - this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"'); + if (this.traceEnabled) { + this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"'); + } this.callEventTracker.onCallEnd(this.finalStatus); process.nextTick(() => { this.listener.onReceiveStatus(this.finalStatus); @@ -63828,8 +63878,13 @@ var require_subchannel_call = __commonJS({ this.http2Stream.resume(); } } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text); + } } /** * On first call, emits a 'status' event with the given StatusObject. @@ -63851,7 +63906,9 @@ var require_subchannel_call = __commonJS({ } } push(message) { - this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null)); + if (this.traceEnabled) { + this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null)); + } this.canPush = false; this.isPushPending = true; process.nextTick(() => { @@ -63868,18 +63925,22 @@ var require_subchannel_call = __commonJS({ this.http2Stream.pause(); this.push(messageBytes); } else { - this.trace("unpushedReadMessages.push message of length " + messageBytes.length); + if (this.traceEnabled) { + this.trace("unpushedReadMessages.push message of length " + messageBytes.length); + } this.unpushedReadMessages.push(messageBytes); } } handleTrailers(headers) { this.serverEndedCall = true; this.callEventTracker.onStreamEnd(true); - let headersString = ""; - for (const header of Object.keys(headers)) { - headersString += " " + header + ": " + headers[header] + "\n"; + if (this.traceEnabled) { + let headersString = ""; + for (const header of Object.keys(headers)) { + headersString += " " + header + ": " + headers[header] + "\n"; + } + this.trace("Received server trailers:\n" + headersString); } - this.trace("Received server trailers:\n" + headersString); let metadata; try { metadata = metadata_1.Metadata.fromHttp2Headers(headers); @@ -63890,7 +63951,9 @@ var require_subchannel_call = __commonJS({ let status; if (typeof metadataMap["grpc-status"] === "string") { const receivedStatus = Number(metadataMap["grpc-status"]); - this.trace("received status code " + receivedStatus + " from server"); + if (this.traceEnabled) { + this.trace("received status code " + receivedStatus + " from server"); + } metadata.remove("grpc-status"); let details = ""; if (typeof metadataMap["grpc-message"] === "string") { @@ -63900,7 +63963,9 @@ var require_subchannel_call = __commonJS({ details = metadataMap["grpc-message"]; } metadata.remove("grpc-message"); - this.trace('received status details string "' + details + '" from server'); + if (this.traceEnabled) { + this.trace('received status details string "' + details + '" from server'); + } } status = { code: receivedStatus, @@ -63925,7 +63990,9 @@ var require_subchannel_call = __commonJS({ return; } if (this.serverEndedCall) { - this.http2Stream.end(); + if (!this.http2Stream.writableEnded) { + this.http2Stream.end(); + } } else { let code; if (((_a = this.finalStatus) === null || _a === void 0 ? void 0 : _a.code) === constants_1.Status.OK) { @@ -63933,12 +64000,16 @@ var require_subchannel_call = __commonJS({ } else { code = http2.constants.NGHTTP2_CANCEL; } - this.trace("close http2 stream with code " + code); + if (this.traceEnabled) { + this.trace("close http2 stream with code " + code); + } this.http2Stream.close(code); } } cancelWithStatus(status, details) { - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } this.endCall({ code: status, details, metadata: new metadata_1.Metadata() }); } getStatus() { @@ -63968,7 +64039,9 @@ var require_subchannel_call = __commonJS({ this.http2Stream.resume(); } sendMessageWithContext(context, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } const cb = (error2) => { process.nextTick(() => { var _a; @@ -63982,7 +64055,9 @@ var require_subchannel_call = __commonJS({ (_a = context.callback) === null || _a === void 0 ? void 0 : _a.call(context); }); }; - this.trace("sending data chunk of length " + message.length); + if (this.traceEnabled) { + this.trace("sending data chunk of length " + message.length); + } this.callEventTracker.addMessageSent(); try { this.http2Stream.write(message, cb); @@ -63996,6 +64071,9 @@ var require_subchannel_call = __commonJS({ } halfClose() { this.trace("end() called"); + if (this.http2Stream.destroyed || this.http2Stream.writableEnded) { + return; + } this.trace("calling end() on HTTP/2 stream"); this.http2Stream.end(); } @@ -64081,18 +64159,24 @@ var require_transport = __commonJS({ if (errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && opaqueData && opaqueData.equals(tooManyPingsData)) { tooManyPings = true; } - this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === void 0 ? void 0 : opaqueData.toString())); + if (this.traceEnabled) { + this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === void 0 ? void 0 : opaqueData.toString())); + } this.reportDisconnectToOwner(tooManyPings); }); session.once("error", (error2) => { - this.trace("connection closed with error " + error2.message); + if (this.traceEnabled) { + this.trace("connection closed with error " + error2.message); + } this.handleDisconnect(); }); session.socket.once("close", (hadError) => { - this.trace("connection closed. hadError=" + hadError); + if (this.traceEnabled) { + this.trace("connection closed. hadError=" + hadError); + } this.handleDisconnect(); }); - if (logging.isTracerEnabled(TRACER_NAME)) { + if (this.traceEnabled) { session.on("remoteSettings", (settings) => { this.trace("new settings received" + (this.session !== session ? " on the old connection" : "") + ": " + JSON.stringify(settings)); }); @@ -64103,7 +64187,7 @@ var require_transport = __commonJS({ if (this.keepaliveWithoutCalls) { this.maybeStartKeepalivePingTimer(); } - if (session.socket instanceof tls_1.TLSSocket) { + if (session.socket instanceof tls_1.TLSSocket && session.socket.authorized) { this.authContext = { transportSecurityType: "ssl", sslPeerCertificate: session.socket.getPeerCertificate() @@ -64152,17 +64236,37 @@ var require_transport = __commonJS({ }; return socketInfo; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } + get keepaliveTraceEnabled() { + return logging.isTracerEnabled("keepalive"); + } + get flowControlTraceEnabled() { + return logging.isTracerEnabled(FLOW_CONTROL_TRACER_NAME); + } + get internalsTraceEnabled() { + return logging.isTracerEnabled("transport_internals"); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } keepaliveTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.keepaliveTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } flowControlTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.flowControlTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } internalsTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.internalsTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } /** * Indicate to the owner of this object that this transport should no longer @@ -64212,7 +64316,9 @@ var require_transport = __commonJS({ if (this.channelzEnabled) { this.keepalivesSent += 1; } - this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms"); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms"); + } this.keepaliveTimer = setTimeout(() => { this.keepaliveTimer = null; this.keepaliveTrace("Ping timeout passed without response"); @@ -64224,7 +64330,9 @@ var require_transport = __commonJS({ const pingSentSuccessfully = this.session.ping((err, duration, payload) => { this.clearKeepaliveTimeout(); if (err) { - this.keepaliveTrace("Ping failed with error " + err.message); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Ping failed with error " + err.message); + } this.handleDisconnect(); } else { this.keepaliveTrace("Received ping response"); @@ -64238,7 +64346,9 @@ var require_transport = __commonJS({ pingSendError = (e instanceof Error ? e.message : "") || "Unknown error"; } if (pingSendError) { - this.keepaliveTrace("Ping send failed: " + pingSendError); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Ping send failed: " + pingSendError); + } this.handleDisconnect(); } } @@ -64289,7 +64399,7 @@ var require_transport = __commonJS({ } } } - createCall(metadata, host, method, listener, subchannelCallStatsTracker) { + createCall(metadata, host, method, listener, subchannelCallStatsTracker, callId) { const headers = metadata.toHttp2Headers(); headers[HTTP2_HEADER_AUTHORITY] = host; headers[HTTP2_HEADER_USER_AGENT] = this.userAgent; @@ -64304,8 +64414,12 @@ var require_transport = __commonJS({ this.handleDisconnect(); throw e; } - this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize); - this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed); + if (this.flowControlTraceEnabled) { + this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize); + } + if (this.internalsTraceEnabled) { + this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed); + } let eventTracker; let call; if (this.channelzEnabled) { @@ -64359,7 +64473,7 @@ var require_transport = __commonJS({ } }; } - call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, (0, call_number_1.getNextCallNumber)()); + call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, callId !== null && callId !== void 0 ? callId : (0, call_number_1.getNextCallNumber)()); this.addActiveCall(call); return call; } @@ -64386,8 +64500,13 @@ var require_transport = __commonJS({ this.session = null; this.isShutdown = false; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text); + } } createSession(secureConnectResult, address, options) { if (this.isShutdown) { @@ -64424,7 +64543,9 @@ var require_transport = __commonJS({ var _a2; (_a2 = this.session) === null || _a2 === void 0 ? void 0 : _a2.destroy(); errorMessage = error2.message; - this.trace("connection failed with error " + errorMessage); + if (this.traceEnabled) { + this.trace("connection failed with error " + errorMessage); + } if (!reportedError) { reportedError = true; reject(`${errorMessage} (${(/* @__PURE__ */ new Date()).toISOString()})`); @@ -64505,14 +64626,22 @@ var require_transport = __commonJS({ let secureConnectResult = null; const addressString = (0, subchannel_address_1.subchannelAddressToString)(address); try { - this.trace(addressString + " Waiting for secureConnector to be ready"); + if (this.traceEnabled) { + this.trace(addressString + " Waiting for secureConnector to be ready"); + } await secureConnector.waitForReady(); - this.trace(addressString + " secureConnector is ready"); + if (this.traceEnabled) { + this.trace(addressString + " secureConnector is ready"); + } tcpConnection = await this.tcpConnect(address, options); tcpConnection.setNoDelay(); - this.trace(addressString + " Established TCP connection"); + if (this.traceEnabled) { + this.trace(addressString + " Established TCP connection"); + } secureConnectResult = await secureConnector.connect(tcpConnection); - this.trace(addressString + " Established secure connection"); + if (this.traceEnabled) { + this.trace(addressString + " Established secure connection"); + } return this.createSession(secureConnectResult, address, options); } catch (e) { tcpConnection === null || tcpConnection === void 0 ? void 0 : tcpConnection.destroy(); @@ -64693,17 +64822,28 @@ var require_load_balancing_call = __commonJS({ } return deadlineInfo; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } + } + getSubchannelString(subchannel) { + return subchannel ? "(" + subchannel.getChannelzRef().id + ") " + subchannel.getAddress() : "" + subchannel; } outputStatus(status, progress) { var _a, _b; if (!this.ended) { this.ended = true; - this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString()); + if (this.traceEnabled) { + this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString()); + } const finalStatus = Object.assign(Object.assign({}, status), { progress }); (_a = this.listener) === null || _a === void 0 ? void 0 : _a.onReceiveStatus(finalStatus); (_b = this.onCallEnded) === null || _b === void 0 ? void 0 : _b.call(this, finalStatus.code, finalStatus.details, finalStatus.metadata); + this.channel.removeCallFromPickQueue(this); } } doPick() { @@ -64717,8 +64857,9 @@ var require_load_balancing_call = __commonJS({ this.trace("Pick called"); const finalMetadata = this.metadata.clone(); const pickResult = this.channel.doPick(finalMetadata, this.callConfig.pickInformation); - const subchannelString = pickResult.subchannel ? "(" + pickResult.subchannel.getChannelzRef().id + ") " + pickResult.subchannel.getAddress() : "" + pickResult.subchannel; - this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + subchannelString + " status: " + ((_a = pickResult.status) === null || _a === void 0 ? void 0 : _a.code) + " " + ((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details)); + if (this.traceEnabled) { + this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + this.getSubchannelString(pickResult.subchannel) + " status: " + ((_a = pickResult.status) === null || _a === void 0 ? void 0 : _a.code) + " " + ((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details)); + } switch (pickResult.pickResultType) { case picker_1.PickResultType.COMPLETE: const combinedCallCredentials = this.credentials.compose(pickResult.subchannel.getCallCredentials()); @@ -64737,7 +64878,9 @@ var require_load_balancing_call = __commonJS({ }, "PROCESSED"); } if (pickResult.subchannel.getConnectivityState() !== connectivity_state_1.ConnectivityState.READY) { - this.trace("Picked subchannel " + subchannelString + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick"); + if (this.traceEnabled) { + this.trace("Picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick"); + } this.doPick(); return; } @@ -64762,10 +64905,12 @@ var require_load_balancing_call = __commonJS({ this.outputStatus(status, "PROCESSED"); } } - }); + }, this.callNumber); this.childStartTime = /* @__PURE__ */ new Date(); } catch (error2) { - this.trace("Failed to start call on picked subchannel " + subchannelString + " with error " + error2.message); + if (this.traceEnabled) { + this.trace("Failed to start call on picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " with error " + error2.message); + } this.outputStatus({ code: constants_1.Status.INTERNAL, details: "Failed to start HTTP/2 stream with error " + error2.message, @@ -64775,7 +64920,9 @@ var require_load_balancing_call = __commonJS({ } (_a2 = pickResult.onCallStarted) === null || _a2 === void 0 ? void 0 : _a2.call(pickResult); this.onCallEnded = pickResult.onCallEnded; - this.trace("Created child call [" + this.child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Created child call [" + this.child.getCallNumber() + "]"); + } if (this.readPending) { this.child.startRead(); } @@ -64816,7 +64963,9 @@ var require_load_balancing_call = __commonJS({ } cancelWithStatus(status, details) { var _a; - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } (_a = this.child) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(status, details); this.outputStatus({ code: status, details, metadata: new metadata_1.Metadata() }, "PROCESSED"); } @@ -64831,7 +64980,9 @@ var require_load_balancing_call = __commonJS({ this.doPick(); } sendMessageWithContext(context, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } if (this.child) { this.child.sendMessageWithContext(context, message); } else { @@ -64918,23 +65069,34 @@ var require_resolving_call = __commonJS({ }); } if (options.flags & constants_1.Propagate.DEADLINE) { - this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline()); + if (this.traceEnabled) { + this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline()); + } this.deadline = (0, deadline_1.minDeadline)(this.deadline, options.parentCall.getDeadline()); } } this.trace("Created"); this.runDeadlineTimer(); } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } } runDeadlineTimer() { clearTimeout(this.deadlineTimer); this.deadlineStartTime = /* @__PURE__ */ new Date(); - this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline)); + if (this.traceEnabled) { + this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline)); + } const timeout = (0, deadline_1.getRelativeTimeout)(this.deadline); if (timeout !== Infinity) { - this.trace("Deadline will be reached in " + timeout + "ms"); + if (this.traceEnabled) { + this.trace("Deadline will be reached in " + timeout + "ms"); + } const handleDeadline = () => { if (!this.deadlineStartTime) { this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, "Deadline exceeded"); @@ -64977,7 +65139,9 @@ var require_resolving_call = __commonJS({ } clearTimeout(this.deadlineTimer); const filteredStatus = this.filterStack.receiveTrailers(status); - this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"'); + if (this.traceEnabled) { + this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"'); + } this.statusWatchers.forEach((watcher) => watcher(filteredStatus)); process.nextTick(() => { var _a; @@ -64998,7 +65162,8 @@ var require_resolving_call = __commonJS({ child.halfClose(); } }, (status) => { - this.cancelWithStatus(status.code, status.details); + var _a, _b; + this.cancelWithStatus((_a = status.code) !== null && _a !== void 0 ? _a : constants_1.Status.INTERNAL, (_b = status.details) !== null && _b !== void 0 ? _b : "Failed to write message"); }); } getConfig() { @@ -65041,8 +65206,10 @@ var require_resolving_call = __commonJS({ this.filterStackFactory.push(config.dynamicFilterFactories); this.filterStack = this.filterStackFactory.createFilter(); this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then((filteredMetadata) => { - this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline); - this.trace("Created child [" + this.child.getCallNumber() + "]"); + this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline, this.callNumber); + if (this.traceEnabled) { + this.trace("Created child [" + this.child.getCallNumber() + "]"); + } this.childStartTime = /* @__PURE__ */ new Date(); this.child.start(filteredMetadata, { onReceiveMetadata: (metadata) => { @@ -65094,7 +65261,9 @@ var require_resolving_call = __commonJS({ } cancelWithStatus(status, details) { var _a; - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } (_a = this.child) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(status, details); this.outputStatus({ code: status, @@ -65113,7 +65282,9 @@ var require_resolving_call = __commonJS({ this.getConfig(); } sendMessageWithContext(context, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } if (this.child) { this.sendMessageOnChild(context, message); } else { @@ -65167,6 +65338,7 @@ var require_retrying_call = __commonJS({ var deadline_1 = require_deadline(); var metadata_1 = require_metadata(); var logging = require_logging(); + var call_number_1 = require_call_number(); var TRACER_NAME = "retrying_call"; var RetryThrottler = class { constructor(maxTokens, tokenRatio, previousRetryThrottler) { @@ -65291,11 +65463,18 @@ var require_retrying_call = __commonJS({ getCallNumber() { return this.callNumber; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } } reportStatus(statusObject) { - this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString()); + if (this.traceEnabled) { + this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString()); + } this.bufferTracker.freeAll(this.callNumber); this.writeBufferOffset = this.writeBufferOffset + this.writeBuffer.length; this.writeBuffer = []; @@ -65309,7 +65488,9 @@ var require_retrying_call = __commonJS({ }); } cancelWithStatus(status, details) { - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } this.reportStatus({ code: status, details, metadata: new metadata_1.Metadata() }); for (const { call } of this.underlyingCalls) { call.cancelWithStatus(status, details); @@ -65356,7 +65537,9 @@ var require_retrying_call = __commonJS({ if (this.state === "COMMITTED") { return; } - this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index); + if (this.traceEnabled) { + this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index); + } this.state = "COMMITTED"; (_b = (_a = this.callConfig).onCommitted) === null || _b === void 0 ? void 0 : _b.call(_a); this.committedCallIndex = index; @@ -65523,7 +65706,9 @@ var require_retrying_call = __commonJS({ if (this.underlyingCalls[callIndex].state === "COMPLETED") { return; } - this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state); + if (this.traceEnabled) { + this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state); + } this.underlyingCalls[callIndex].state = "COMPLETED"; if (status.code === constants_1.Status.OK) { (_a = this.retryThrottler) === null || _a === void 0 ? void 0 : _a.addCallSucceeded(); @@ -65599,8 +65784,11 @@ var require_retrying_call = __commonJS({ (_c = (_b = this.hedgingTimer).unref) === null || _c === void 0 ? void 0 : _c.call(_b); } startNewAttempt() { - const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline); - this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts); + const childCallNumber = this.underlyingCalls.length > 0 ? (0, call_number_1.getNextCallNumber)() : this.callNumber; + const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline, childCallNumber); + if (this.traceEnabled) { + this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts); + } const index = this.underlyingCalls.length; this.underlyingCalls.push({ state: "ACTIVE", @@ -65616,7 +65804,9 @@ var require_retrying_call = __commonJS({ let receivedMetadata = false; child.start(initialMetadata, { onReceiveMetadata: (metadata) => { - this.trace("Received metadata from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received metadata from child [" + child.getCallNumber() + "]"); + } this.commitCall(index); receivedMetadata = true; if (previousAttempts > 0) { @@ -65627,14 +65817,18 @@ var require_retrying_call = __commonJS({ } }, onReceiveMessage: (message) => { - this.trace("Received message from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received message from child [" + child.getCallNumber() + "]"); + } this.commitCall(index); if (this.underlyingCalls[index].state === "ACTIVE") { this.listener.onReceiveMessage(message); } }, onReceiveStatus: (status) => { - this.trace("Received status from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received status from child [" + child.getCallNumber() + "]"); + } if (!receivedMetadata && previousAttempts > 0) { status.metadata.set(PREVIONS_RPC_ATTEMPTS_METADATA_KEY, `${previousAttempts}`); } @@ -65679,7 +65873,9 @@ var require_retrying_call = __commonJS({ }, bufferEntry.message.message); const nextEntry = this.getBufferEntry(messageIndex + 1); if (nextEntry.entryType === "HALF_CLOSE") { - this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message"); + if (this.traceEnabled) { + this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message"); + } childCall.nextMessageToSend += 1; childCall.call.halfClose(); } @@ -65694,7 +65890,9 @@ var require_retrying_call = __commonJS({ } } sendMessageWithContext(context, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } const writeObj = { message, flags: context.flags @@ -65755,7 +65953,9 @@ var require_retrying_call = __commonJS({ for (const call of this.underlyingCalls) { if ((call === null || call === void 0 ? void 0 : call.state) === "ACTIVE") { if (call.nextMessageToSend === halfCloseIndex || call.nextMessageToSend === halfCloseIndex - 1) { - this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent"); + if (this.traceEnabled) { + this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent"); + } call.nextMessageToSend += 1; call.call.halfClose(); } @@ -65985,7 +66185,7 @@ var require_internal_channel = __commonJS({ this.connectivityState = connectivity_state_1.ConnectivityState.IDLE; this.currentPicker = new picker_1.UnavailablePicker(); this.configSelectionQueue = []; - this.pickQueue = []; + this.pickQueue = /* @__PURE__ */ new Set(); this.connectivityStateWatchers = []; this.callRefTimer = null; this.configSelector = null; @@ -66052,9 +66252,9 @@ var require_internal_channel = __commonJS({ }, updateState: (connectivityState, picker) => { this.currentPicker = picker; - const queueCopy = this.pickQueue.slice(); - this.pickQueue = []; - if (queueCopy.length > 0) { + const queueCopy = this.pickQueue; + this.pickQueue = /* @__PURE__ */ new Set(); + if (queueCopy.size > 0) { this.callRefTimerUnref(); } for (const call of queueCopy) { @@ -66121,15 +66321,22 @@ var require_internal_channel = __commonJS({ this.filterStackFactory = new filter_stack_1.FilterStackFactory([ new compression_filter_1.CompressionFilterFactory(this, this.options) ]); - this.trace("Channel constructed with options " + JSON.stringify(options, void 0, 2)); - const error2 = new Error(); + if (this.traceEnabled) { + this.trace("Channel constructed with options " + JSON.stringify(options, void 0, 2)); + } if ((0, logging_1.isTracerEnabled)("channel_stacktrace")) { + const error2 = new Error(); (0, logging_1.trace)(constants_1.LogVerbosity.DEBUG, "channel_stacktrace", "(" + this.channelzRef.id + ") Channel constructed \n" + ((_f = error2.stack) === null || _f === void 0 ? void 0 : _f.substring(error2.stack.indexOf("\n") + 1))); } this.lastActivityTimestamp = /* @__PURE__ */ new Date(); } + get traceEnabled() { + return (0, logging_1.isTracerEnabled)("channel"); + } trace(text, verbosityOverride) { - (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text); + if (this.traceEnabled) { + (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text); + } } callRefTimerRef() { var _a, _b, _c, _d; @@ -66138,14 +66345,18 @@ var require_internal_channel = __commonJS({ }, MAX_TIMEOUT_TIME); } if (!((_b = (_a = this.callRefTimer).hasRef) === null || _b === void 0 ? void 0 : _b.call(_a))) { - this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length); + if (this.traceEnabled) { + this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size); + } (_d = (_c = this.callRefTimer).ref) === null || _d === void 0 ? void 0 : _d.call(_c); } } callRefTimerUnref() { var _a, _b, _c; if (!((_a = this.callRefTimer) === null || _a === void 0 ? void 0 : _a.hasRef) || this.callRefTimer.hasRef()) { - this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length); + if (this.traceEnabled) { + this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size); + } (_c = (_b = this.callRefTimer) === null || _b === void 0 ? void 0 : _b.unref) === null || _c === void 0 ? void 0 : _c.call(_b); } } @@ -66197,9 +66408,15 @@ var require_internal_channel = __commonJS({ }); } queueCallForPick(call) { - this.pickQueue.push(call); + this.pickQueue.add(call); this.callRefTimerRef(); } + removeCallFromPickQueue(call) { + this.pickQueue.delete(call); + if (this.pickQueue.size === 0) { + this.callRefTimerUnref(); + } + } getConfig(method, metadata) { if (this.connectivityState !== connectivity_state_1.ConnectivityState.SHUTDOWN) { this.resolvingLoadBalancer.exitIdle(); @@ -66280,19 +66497,25 @@ var require_internal_channel = __commonJS({ this.lastActivityTimestamp = /* @__PURE__ */ new Date(); this.maybeStartIdleTimer(); } - createLoadBalancingCall(callConfig, method, host, credentials, deadline) { - const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createLoadBalancingCall [" + callNumber + '] method="' + method + '"'); - return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, callNumber); + createLoadBalancingCall(callConfig, method, host, credentials, deadline, callNumber) { + const finalCallNumber = callNumber !== null && callNumber !== void 0 ? callNumber : (0, call_number_1.getNextCallNumber)(); + if (this.traceEnabled) { + this.trace("createLoadBalancingCall [" + finalCallNumber + '] method="' + method + '"'); + } + return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber); } - createRetryingCall(callConfig, method, host, credentials, deadline) { - const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createRetryingCall [" + callNumber + '] method="' + method + '"'); - return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget())); + createRetryingCall(callConfig, method, host, credentials, deadline, callNumber) { + const finalCallNumber = callNumber !== null && callNumber !== void 0 ? callNumber : (0, call_number_1.getNextCallNumber)(); + if (this.traceEnabled) { + this.trace("createRetryingCall [" + finalCallNumber + '] method="' + method + '"'); + } + return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget())); } createResolvingCall(method, deadline, host, parentCall, propagateFlags) { const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline)); + if (this.traceEnabled) { + this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline)); + } const finalOptions = { deadline, flags: propagateFlags !== null && propagateFlags !== void 0 ? propagateFlags : constants_1.Propagate.DEFAULTS, @@ -66318,7 +66541,7 @@ var require_internal_channel = __commonJS({ for (const call of this.pickQueue) { call.cancelWithStatus(constants_1.Status.UNAVAILABLE, "Channel closed before call started"); } - this.pickQueue = []; + this.pickQueue.clear(); if (this.callRefTimer) { clearInterval(this.callRefTimer); } @@ -68026,15 +68249,17 @@ var require_server_interceptors = __commonJS({ } getAuthContext() { var _a; - if (((_a = this.stream.session) === null || _a === void 0 ? void 0 : _a.socket) instanceof tls_1.TLSSocket) { - const peerCertificate = this.stream.session.socket.getPeerCertificate(); - return { - transportSecurityType: "ssl", - sslPeerCertificate: peerCertificate.raw ? peerCertificate : void 0 - }; - } else { + if (!(((_a = this.stream.session) === null || _a === void 0 ? void 0 : _a.socket) instanceof tls_1.TLSSocket)) { return {}; } + if (!this.stream.session.socket.authorized) { + return {}; + } + const peerCertificate = this.stream.session.socket.getPeerCertificate(); + return { + transportSecurityType: "ssl", + sslPeerCertificate: peerCertificate.raw ? peerCertificate : void 0 + }; } getConnectionInfo() { return this.connectionInfo; @@ -68116,6 +68341,7 @@ var require_server2 = __commonJS({ var uri_parser_1 = require_uri_parser(); var channelz_1 = require_channelz(); var server_interceptors_1 = require_server_interceptors(); + var environment_1 = require_environment(); var UNLIMITED_CONNECTION_AGE_MS = ~(1 << 31); var KEEPALIVE_MAX_TIME_MS = ~(1 << 31); var KEEPALIVE_TIMEOUT_MS = 2e4; @@ -69369,9 +69595,15 @@ var require_server2 = __commonJS({ try { handler.func(stream, respond); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -69405,9 +69637,15 @@ var require_server2 = __commonJS({ try { handler.func(stream, respond); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -69461,9 +69699,15 @@ var require_server2 = __commonJS({ try { handler.func(stream); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -69485,9 +69729,15 @@ var require_server2 = __commonJS({ try { handler.func(stream); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } diff --git a/dist/main.js b/dist/main.js index 509ca1b5a..7bbd7d466 100644 --- a/dist/main.js +++ b/dist/main.js @@ -48308,7 +48308,7 @@ var require_package2 = __commonJS({ "node_modules/@grpc/grpc-js/package.json"(exports2, module2) { module2.exports = { name: "@grpc/grpc-js", - version: "1.14.4", + version: "1.14.5", description: "gRPC Library for Node - pure JS implementation", homepage: "https://grpc.io/", repository: "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", @@ -48481,6 +48481,9 @@ var require_logging = __commonJS({ var enabledTracers = /* @__PURE__ */ new Set(); var disabledTracers = /* @__PURE__ */ new Set(); for (const tracerName of tracersString.split(",")) { + if (tracerName.length === 0) { + continue; + } if (tracerName.startsWith("-")) { disabledTracers.add(tracerName.substring(1)); } else { @@ -48488,12 +48491,16 @@ var require_logging = __commonJS({ } } var allEnabled = enabledTracers.has("all"); + var anyTracerEnabled = allEnabled || enabledTracers.size > 0; function trace(severity, tracer, text) { if (isTracerEnabled(tracer)) { (0, exports2.log)(severity, (/* @__PURE__ */ new Date()).toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " + text); } } function isTracerEnabled(tracer) { + if (!anyTracerEnabled) { + return false; + } return !disabledTracers.has(tracer) && (allEnabled || enabledTracers.has(tracer)); } } @@ -50019,7 +50026,9 @@ var require_backoff_timeout = __commonJS({ this.maxDelay = options.maxDelay; } } - this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay); + if (this.traceEnabled) { + this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay); + } this.nextDelay = this.initialDelay; this.timerId = setTimeout(() => { }, 0); @@ -50028,12 +50037,19 @@ var require_backoff_timeout = __commonJS({ static getNextId() { return this.nextId++; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text); + } } runTimer(delay) { var _a, _b; - this.trace("runTimer(delay=" + delay + ")"); + if (this.traceEnabled) { + this.trace("runTimer(delay=" + delay + ")"); + } this.endTime = this.startTime; this.endTime.setMilliseconds(this.endTime.getMilliseconds() + delay); clearTimeout(this.timerId); @@ -50072,7 +50088,9 @@ var require_backoff_timeout = __commonJS({ * retroactively apply that reset to the current timer. */ reset() { - this.trace("reset() running=" + this.running); + if (this.traceEnabled) { + this.trace("reset() running=" + this.running); + } this.nextDelay = this.initialDelay; if (this.running) { const now = /* @__PURE__ */ new Date(); @@ -63334,7 +63352,7 @@ var require_single_subchannel_channel = __commonJS({ } } }; - this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener); + this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener, this.callNumber); if (this.readPending) { this.childCall.startRead(); } @@ -63504,7 +63522,9 @@ var require_subchannel = __commonJS({ } this.channelzRef = (0, channelz_1.registerChannelzSubchannel)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled); this.channelzTrace.addTrace("CT_INFO", "Subchannel created"); - this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2)); + if (this.traceEnabled) { + this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2)); + } this.secureConnector = credentials._createSecureConnector(channelTarget, options); } getChannelzInfo() { @@ -63516,11 +63536,21 @@ var require_subchannel = __commonJS({ target: this.subchannelAddressString }; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } + get refTraceEnabled() { + return logging.isTracerEnabled("subchannel_refcount"); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } refTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.refTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } handleBackoffTimer() { if (this.continueConnecting) { @@ -63577,10 +63607,12 @@ var require_subchannel = __commonJS({ if (oldStates.indexOf(this.connectivityState) === -1) { return false; } - if (errorMessage) { - this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"'); - } else { - this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]); + if (this.traceEnabled) { + if (errorMessage) { + this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"'); + } else { + this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]); + } } if (this.channelzEnabled) { this.channelzTrace.addTrace("CT_INFO", "Connectivity state change to " + connectivity_state_1.ConnectivityState[newState]); @@ -63624,11 +63656,15 @@ var require_subchannel = __commonJS({ return true; } ref() { - this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1)); + if (this.refTraceEnabled) { + this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1)); + } this.refcount += 1; } unref() { - this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1)); + if (this.refTraceEnabled) { + this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1)); + } this.refcount -= 1; if (this.refcount === 0) { this.channelzTrace.addTrace("CT_INFO", "Shutting down"); @@ -63646,7 +63682,7 @@ var require_subchannel = __commonJS({ } return false; } - createCall(metadata, host, method, listener) { + createCall(metadata, host, method, listener, callId) { if (!this.transport) { throw new Error("Cannot create call, subchannel not READY"); } @@ -63666,7 +63702,7 @@ var require_subchannel = __commonJS({ } else { statsTracker = {}; } - return this.transport.createCall(metadata, host, method, listener, statsTracker); + return this.transport.createCall(metadata, host, method, listener, statsTracker, callId); } /** * If the subchannel is currently IDLE, start connecting and switch to the @@ -63772,9 +63808,11 @@ var require_environment = __commonJS({ "node_modules/@grpc/grpc-js/build/src/environment.js"(exports2) { "use strict"; var _a; + var _b; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = void 0; + exports2.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = void 0; exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = ((_a = process.env.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) !== null && _a !== void 0 ? _a : "false") === "true"; + exports2.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = ((_b = process.env.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) !== null && _b !== void 0 ? _b : "false") === "true"; } }); @@ -64445,11 +64483,13 @@ var require_subchannel_call = __commonJS({ const maxReceiveMessageLength = (_a = transport.getOptions()["grpc.max_receive_message_length"]) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH; this.decoder = new stream_decoder_1.StreamDecoder(maxReceiveMessageLength); http2Stream.on("response", (headers, flags) => { - let headersString = ""; - for (const header of Object.keys(headers)) { - headersString += " " + header + ": " + headers[header] + "\n"; + if (this.traceEnabled) { + let headersString = ""; + for (const header of Object.keys(headers)) { + headersString += " " + header + ": " + headers[header] + "\n"; + } + this.trace("Received server headers:\n" + headersString); } - this.trace("Received server headers:\n" + headersString); this.httpStatusCode = headers[":status"]; if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) { this.handleTrailers(headers); @@ -64475,7 +64515,9 @@ var require_subchannel_call = __commonJS({ if (this.statusOutput) { return; } - this.trace("receive HTTP/2 data frame of length " + data.length); + if (this.traceEnabled) { + this.trace("receive HTTP/2 data frame of length " + data.length); + } let messages; try { messages = this.decoder.write(data); @@ -64489,7 +64531,9 @@ var require_subchannel_call = __commonJS({ return; } for (const message of messages) { - this.trace("parsed message of length " + message.length); + if (this.traceEnabled) { + this.trace("parsed message of length " + message.length); + } this.callEventTracker.addMessageReceived(); this.tryPush(message); } @@ -64502,7 +64546,9 @@ var require_subchannel_call = __commonJS({ this.serverEndedCall = true; process.nextTick(() => { var _a2; - this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode); + if (this.traceEnabled) { + this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode); + } if (((_a2 = this.finalStatus) === null || _a2 === void 0 ? void 0 : _a2.code) === constants_1.Status.OK) { return; } @@ -64570,7 +64616,9 @@ var require_subchannel_call = __commonJS({ }); http2Stream.on("error", (err) => { if (err.code !== "ERR_HTTP2_STREAM_ERROR") { - this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall); + if (this.traceEnabled) { + this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall); + } this.internalError = err; } this.callEventTracker.onStreamEnd(false); @@ -64592,7 +64640,9 @@ var require_subchannel_call = __commonJS({ outputStatus() { if (!this.statusOutput) { this.statusOutput = true; - this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"'); + if (this.traceEnabled) { + this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"'); + } this.callEventTracker.onCallEnd(this.finalStatus); process.nextTick(() => { this.listener.onReceiveStatus(this.finalStatus); @@ -64600,8 +64650,13 @@ var require_subchannel_call = __commonJS({ this.http2Stream.resume(); } } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text); + } } /** * On first call, emits a 'status' event with the given StatusObject. @@ -64623,7 +64678,9 @@ var require_subchannel_call = __commonJS({ } } push(message) { - this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null)); + if (this.traceEnabled) { + this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null)); + } this.canPush = false; this.isPushPending = true; process.nextTick(() => { @@ -64640,18 +64697,22 @@ var require_subchannel_call = __commonJS({ this.http2Stream.pause(); this.push(messageBytes); } else { - this.trace("unpushedReadMessages.push message of length " + messageBytes.length); + if (this.traceEnabled) { + this.trace("unpushedReadMessages.push message of length " + messageBytes.length); + } this.unpushedReadMessages.push(messageBytes); } } handleTrailers(headers) { this.serverEndedCall = true; this.callEventTracker.onStreamEnd(true); - let headersString = ""; - for (const header of Object.keys(headers)) { - headersString += " " + header + ": " + headers[header] + "\n"; + if (this.traceEnabled) { + let headersString = ""; + for (const header of Object.keys(headers)) { + headersString += " " + header + ": " + headers[header] + "\n"; + } + this.trace("Received server trailers:\n" + headersString); } - this.trace("Received server trailers:\n" + headersString); let metadata; try { metadata = metadata_1.Metadata.fromHttp2Headers(headers); @@ -64662,7 +64723,9 @@ var require_subchannel_call = __commonJS({ let status; if (typeof metadataMap["grpc-status"] === "string") { const receivedStatus = Number(metadataMap["grpc-status"]); - this.trace("received status code " + receivedStatus + " from server"); + if (this.traceEnabled) { + this.trace("received status code " + receivedStatus + " from server"); + } metadata.remove("grpc-status"); let details = ""; if (typeof metadataMap["grpc-message"] === "string") { @@ -64672,7 +64735,9 @@ var require_subchannel_call = __commonJS({ details = metadataMap["grpc-message"]; } metadata.remove("grpc-message"); - this.trace('received status details string "' + details + '" from server'); + if (this.traceEnabled) { + this.trace('received status details string "' + details + '" from server'); + } } status = { code: receivedStatus, @@ -64697,7 +64762,9 @@ var require_subchannel_call = __commonJS({ return; } if (this.serverEndedCall) { - this.http2Stream.end(); + if (!this.http2Stream.writableEnded) { + this.http2Stream.end(); + } } else { let code; if (((_a = this.finalStatus) === null || _a === void 0 ? void 0 : _a.code) === constants_1.Status.OK) { @@ -64705,12 +64772,16 @@ var require_subchannel_call = __commonJS({ } else { code = http2.constants.NGHTTP2_CANCEL; } - this.trace("close http2 stream with code " + code); + if (this.traceEnabled) { + this.trace("close http2 stream with code " + code); + } this.http2Stream.close(code); } } cancelWithStatus(status, details) { - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } this.endCall({ code: status, details, metadata: new metadata_1.Metadata() }); } getStatus() { @@ -64740,7 +64811,9 @@ var require_subchannel_call = __commonJS({ this.http2Stream.resume(); } sendMessageWithContext(context3, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } const cb = (error2) => { process.nextTick(() => { var _a; @@ -64754,7 +64827,9 @@ var require_subchannel_call = __commonJS({ (_a = context3.callback) === null || _a === void 0 ? void 0 : _a.call(context3); }); }; - this.trace("sending data chunk of length " + message.length); + if (this.traceEnabled) { + this.trace("sending data chunk of length " + message.length); + } this.callEventTracker.addMessageSent(); try { this.http2Stream.write(message, cb); @@ -64768,6 +64843,9 @@ var require_subchannel_call = __commonJS({ } halfClose() { this.trace("end() called"); + if (this.http2Stream.destroyed || this.http2Stream.writableEnded) { + return; + } this.trace("calling end() on HTTP/2 stream"); this.http2Stream.end(); } @@ -64853,18 +64931,24 @@ var require_transport = __commonJS({ if (errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && opaqueData && opaqueData.equals(tooManyPingsData)) { tooManyPings = true; } - this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === void 0 ? void 0 : opaqueData.toString())); + if (this.traceEnabled) { + this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === void 0 ? void 0 : opaqueData.toString())); + } this.reportDisconnectToOwner(tooManyPings); }); session.once("error", (error2) => { - this.trace("connection closed with error " + error2.message); + if (this.traceEnabled) { + this.trace("connection closed with error " + error2.message); + } this.handleDisconnect(); }); session.socket.once("close", (hadError) => { - this.trace("connection closed. hadError=" + hadError); + if (this.traceEnabled) { + this.trace("connection closed. hadError=" + hadError); + } this.handleDisconnect(); }); - if (logging.isTracerEnabled(TRACER_NAME)) { + if (this.traceEnabled) { session.on("remoteSettings", (settings) => { this.trace("new settings received" + (this.session !== session ? " on the old connection" : "") + ": " + JSON.stringify(settings)); }); @@ -64875,7 +64959,7 @@ var require_transport = __commonJS({ if (this.keepaliveWithoutCalls) { this.maybeStartKeepalivePingTimer(); } - if (session.socket instanceof tls_1.TLSSocket) { + if (session.socket instanceof tls_1.TLSSocket && session.socket.authorized) { this.authContext = { transportSecurityType: "ssl", sslPeerCertificate: session.socket.getPeerCertificate() @@ -64924,17 +65008,37 @@ var require_transport = __commonJS({ }; return socketInfo; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } + get keepaliveTraceEnabled() { + return logging.isTracerEnabled("keepalive"); + } + get flowControlTraceEnabled() { + return logging.isTracerEnabled(FLOW_CONTROL_TRACER_NAME); + } + get internalsTraceEnabled() { + return logging.isTracerEnabled("transport_internals"); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } keepaliveTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.keepaliveTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } flowControlTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.flowControlTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } internalsTrace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + if (this.internalsTraceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text); + } } /** * Indicate to the owner of this object that this transport should no longer @@ -64984,7 +65088,9 @@ var require_transport = __commonJS({ if (this.channelzEnabled) { this.keepalivesSent += 1; } - this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms"); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms"); + } this.keepaliveTimer = setTimeout(() => { this.keepaliveTimer = null; this.keepaliveTrace("Ping timeout passed without response"); @@ -64996,7 +65102,9 @@ var require_transport = __commonJS({ const pingSentSuccessfully = this.session.ping((err, duration, payload) => { this.clearKeepaliveTimeout(); if (err) { - this.keepaliveTrace("Ping failed with error " + err.message); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Ping failed with error " + err.message); + } this.handleDisconnect(); } else { this.keepaliveTrace("Received ping response"); @@ -65010,7 +65118,9 @@ var require_transport = __commonJS({ pingSendError = (e instanceof Error ? e.message : "") || "Unknown error"; } if (pingSendError) { - this.keepaliveTrace("Ping send failed: " + pingSendError); + if (this.keepaliveTraceEnabled) { + this.keepaliveTrace("Ping send failed: " + pingSendError); + } this.handleDisconnect(); } } @@ -65061,7 +65171,7 @@ var require_transport = __commonJS({ } } } - createCall(metadata, host, method, listener, subchannelCallStatsTracker) { + createCall(metadata, host, method, listener, subchannelCallStatsTracker, callId) { const headers = metadata.toHttp2Headers(); headers[HTTP2_HEADER_AUTHORITY] = host; headers[HTTP2_HEADER_USER_AGENT] = this.userAgent; @@ -65076,8 +65186,12 @@ var require_transport = __commonJS({ this.handleDisconnect(); throw e; } - this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize); - this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed); + if (this.flowControlTraceEnabled) { + this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize); + } + if (this.internalsTraceEnabled) { + this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed); + } let eventTracker; let call; if (this.channelzEnabled) { @@ -65131,7 +65245,7 @@ var require_transport = __commonJS({ } }; } - call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, (0, call_number_1.getNextCallNumber)()); + call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, callId !== null && callId !== void 0 ? callId : (0, call_number_1.getNextCallNumber)()); this.addActiveCall(call); return call; } @@ -65158,8 +65272,13 @@ var require_transport = __commonJS({ this.session = null; this.isShutdown = false; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text); + } } createSession(secureConnectResult, address, options) { if (this.isShutdown) { @@ -65196,7 +65315,9 @@ var require_transport = __commonJS({ var _a2; (_a2 = this.session) === null || _a2 === void 0 ? void 0 : _a2.destroy(); errorMessage = error2.message; - this.trace("connection failed with error " + errorMessage); + if (this.traceEnabled) { + this.trace("connection failed with error " + errorMessage); + } if (!reportedError) { reportedError = true; reject(`${errorMessage} (${(/* @__PURE__ */ new Date()).toISOString()})`); @@ -65277,14 +65398,22 @@ var require_transport = __commonJS({ let secureConnectResult = null; const addressString = (0, subchannel_address_1.subchannelAddressToString)(address); try { - this.trace(addressString + " Waiting for secureConnector to be ready"); + if (this.traceEnabled) { + this.trace(addressString + " Waiting for secureConnector to be ready"); + } await secureConnector.waitForReady(); - this.trace(addressString + " secureConnector is ready"); + if (this.traceEnabled) { + this.trace(addressString + " secureConnector is ready"); + } tcpConnection = await this.tcpConnect(address, options); tcpConnection.setNoDelay(); - this.trace(addressString + " Established TCP connection"); + if (this.traceEnabled) { + this.trace(addressString + " Established TCP connection"); + } secureConnectResult = await secureConnector.connect(tcpConnection); - this.trace(addressString + " Established secure connection"); + if (this.traceEnabled) { + this.trace(addressString + " Established secure connection"); + } return this.createSession(secureConnectResult, address, options); } catch (e) { tcpConnection === null || tcpConnection === void 0 ? void 0 : tcpConnection.destroy(); @@ -65465,17 +65594,28 @@ var require_load_balancing_call = __commonJS({ } return deadlineInfo; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } + } + getSubchannelString(subchannel) { + return subchannel ? "(" + subchannel.getChannelzRef().id + ") " + subchannel.getAddress() : "" + subchannel; } outputStatus(status, progress) { var _a, _b; if (!this.ended) { this.ended = true; - this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString()); + if (this.traceEnabled) { + this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString()); + } const finalStatus = Object.assign(Object.assign({}, status), { progress }); (_a = this.listener) === null || _a === void 0 ? void 0 : _a.onReceiveStatus(finalStatus); (_b = this.onCallEnded) === null || _b === void 0 ? void 0 : _b.call(this, finalStatus.code, finalStatus.details, finalStatus.metadata); + this.channel.removeCallFromPickQueue(this); } } doPick() { @@ -65489,8 +65629,9 @@ var require_load_balancing_call = __commonJS({ this.trace("Pick called"); const finalMetadata = this.metadata.clone(); const pickResult = this.channel.doPick(finalMetadata, this.callConfig.pickInformation); - const subchannelString = pickResult.subchannel ? "(" + pickResult.subchannel.getChannelzRef().id + ") " + pickResult.subchannel.getAddress() : "" + pickResult.subchannel; - this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + subchannelString + " status: " + ((_a = pickResult.status) === null || _a === void 0 ? void 0 : _a.code) + " " + ((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details)); + if (this.traceEnabled) { + this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + this.getSubchannelString(pickResult.subchannel) + " status: " + ((_a = pickResult.status) === null || _a === void 0 ? void 0 : _a.code) + " " + ((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details)); + } switch (pickResult.pickResultType) { case picker_1.PickResultType.COMPLETE: const combinedCallCredentials = this.credentials.compose(pickResult.subchannel.getCallCredentials()); @@ -65509,7 +65650,9 @@ var require_load_balancing_call = __commonJS({ }, "PROCESSED"); } if (pickResult.subchannel.getConnectivityState() !== connectivity_state_1.ConnectivityState.READY) { - this.trace("Picked subchannel " + subchannelString + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick"); + if (this.traceEnabled) { + this.trace("Picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick"); + } this.doPick(); return; } @@ -65534,10 +65677,12 @@ var require_load_balancing_call = __commonJS({ this.outputStatus(status, "PROCESSED"); } } - }); + }, this.callNumber); this.childStartTime = /* @__PURE__ */ new Date(); } catch (error2) { - this.trace("Failed to start call on picked subchannel " + subchannelString + " with error " + error2.message); + if (this.traceEnabled) { + this.trace("Failed to start call on picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " with error " + error2.message); + } this.outputStatus({ code: constants_1.Status.INTERNAL, details: "Failed to start HTTP/2 stream with error " + error2.message, @@ -65547,7 +65692,9 @@ var require_load_balancing_call = __commonJS({ } (_a2 = pickResult.onCallStarted) === null || _a2 === void 0 ? void 0 : _a2.call(pickResult); this.onCallEnded = pickResult.onCallEnded; - this.trace("Created child call [" + this.child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Created child call [" + this.child.getCallNumber() + "]"); + } if (this.readPending) { this.child.startRead(); } @@ -65588,7 +65735,9 @@ var require_load_balancing_call = __commonJS({ } cancelWithStatus(status, details) { var _a; - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } (_a = this.child) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(status, details); this.outputStatus({ code: status, details, metadata: new metadata_1.Metadata() }, "PROCESSED"); } @@ -65603,7 +65752,9 @@ var require_load_balancing_call = __commonJS({ this.doPick(); } sendMessageWithContext(context3, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } if (this.child) { this.child.sendMessageWithContext(context3, message); } else { @@ -65690,23 +65841,34 @@ var require_resolving_call = __commonJS({ }); } if (options.flags & constants_1.Propagate.DEADLINE) { - this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline()); + if (this.traceEnabled) { + this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline()); + } this.deadline = (0, deadline_1.minDeadline)(this.deadline, options.parentCall.getDeadline()); } } this.trace("Created"); this.runDeadlineTimer(); } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } } runDeadlineTimer() { clearTimeout(this.deadlineTimer); this.deadlineStartTime = /* @__PURE__ */ new Date(); - this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline)); + if (this.traceEnabled) { + this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline)); + } const timeout = (0, deadline_1.getRelativeTimeout)(this.deadline); if (timeout !== Infinity) { - this.trace("Deadline will be reached in " + timeout + "ms"); + if (this.traceEnabled) { + this.trace("Deadline will be reached in " + timeout + "ms"); + } const handleDeadline = () => { if (!this.deadlineStartTime) { this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, "Deadline exceeded"); @@ -65749,7 +65911,9 @@ var require_resolving_call = __commonJS({ } clearTimeout(this.deadlineTimer); const filteredStatus = this.filterStack.receiveTrailers(status); - this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"'); + if (this.traceEnabled) { + this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"'); + } this.statusWatchers.forEach((watcher) => watcher(filteredStatus)); process.nextTick(() => { var _a; @@ -65770,7 +65934,8 @@ var require_resolving_call = __commonJS({ child.halfClose(); } }, (status) => { - this.cancelWithStatus(status.code, status.details); + var _a, _b; + this.cancelWithStatus((_a = status.code) !== null && _a !== void 0 ? _a : constants_1.Status.INTERNAL, (_b = status.details) !== null && _b !== void 0 ? _b : "Failed to write message"); }); } getConfig() { @@ -65813,8 +65978,10 @@ var require_resolving_call = __commonJS({ this.filterStackFactory.push(config.dynamicFilterFactories); this.filterStack = this.filterStackFactory.createFilter(); this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then((filteredMetadata) => { - this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline); - this.trace("Created child [" + this.child.getCallNumber() + "]"); + this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline, this.callNumber); + if (this.traceEnabled) { + this.trace("Created child [" + this.child.getCallNumber() + "]"); + } this.childStartTime = /* @__PURE__ */ new Date(); this.child.start(filteredMetadata, { onReceiveMetadata: (metadata) => { @@ -65866,7 +66033,9 @@ var require_resolving_call = __commonJS({ } cancelWithStatus(status, details) { var _a; - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } (_a = this.child) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(status, details); this.outputStatus({ code: status, @@ -65885,7 +66054,9 @@ var require_resolving_call = __commonJS({ this.getConfig(); } sendMessageWithContext(context3, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } if (this.child) { this.sendMessageOnChild(context3, message); } else { @@ -65939,6 +66110,7 @@ var require_retrying_call = __commonJS({ var deadline_1 = require_deadline(); var metadata_1 = require_metadata(); var logging = require_logging(); + var call_number_1 = require_call_number(); var TRACER_NAME = "retrying_call"; var RetryThrottler = class { constructor(maxTokens, tokenRatio, previousRetryThrottler) { @@ -66063,11 +66235,18 @@ var require_retrying_call = __commonJS({ getCallNumber() { return this.callNumber; } + get traceEnabled() { + return logging.isTracerEnabled(TRACER_NAME); + } trace(text) { - logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + if (this.traceEnabled) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text); + } } reportStatus(statusObject) { - this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString()); + if (this.traceEnabled) { + this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString()); + } this.bufferTracker.freeAll(this.callNumber); this.writeBufferOffset = this.writeBufferOffset + this.writeBuffer.length; this.writeBuffer = []; @@ -66081,7 +66260,9 @@ var require_retrying_call = __commonJS({ }); } cancelWithStatus(status, details) { - this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + if (this.traceEnabled) { + this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"'); + } this.reportStatus({ code: status, details, metadata: new metadata_1.Metadata() }); for (const { call } of this.underlyingCalls) { call.cancelWithStatus(status, details); @@ -66128,7 +66309,9 @@ var require_retrying_call = __commonJS({ if (this.state === "COMMITTED") { return; } - this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index); + if (this.traceEnabled) { + this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index); + } this.state = "COMMITTED"; (_b = (_a = this.callConfig).onCommitted) === null || _b === void 0 ? void 0 : _b.call(_a); this.committedCallIndex = index; @@ -66295,7 +66478,9 @@ var require_retrying_call = __commonJS({ if (this.underlyingCalls[callIndex].state === "COMPLETED") { return; } - this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state); + if (this.traceEnabled) { + this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state); + } this.underlyingCalls[callIndex].state = "COMPLETED"; if (status.code === constants_1.Status.OK) { (_a = this.retryThrottler) === null || _a === void 0 ? void 0 : _a.addCallSucceeded(); @@ -66371,8 +66556,11 @@ var require_retrying_call = __commonJS({ (_c = (_b = this.hedgingTimer).unref) === null || _c === void 0 ? void 0 : _c.call(_b); } startNewAttempt() { - const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline); - this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts); + const childCallNumber = this.underlyingCalls.length > 0 ? (0, call_number_1.getNextCallNumber)() : this.callNumber; + const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline, childCallNumber); + if (this.traceEnabled) { + this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts); + } const index = this.underlyingCalls.length; this.underlyingCalls.push({ state: "ACTIVE", @@ -66388,7 +66576,9 @@ var require_retrying_call = __commonJS({ let receivedMetadata = false; child.start(initialMetadata, { onReceiveMetadata: (metadata) => { - this.trace("Received metadata from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received metadata from child [" + child.getCallNumber() + "]"); + } this.commitCall(index); receivedMetadata = true; if (previousAttempts > 0) { @@ -66399,14 +66589,18 @@ var require_retrying_call = __commonJS({ } }, onReceiveMessage: (message) => { - this.trace("Received message from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received message from child [" + child.getCallNumber() + "]"); + } this.commitCall(index); if (this.underlyingCalls[index].state === "ACTIVE") { this.listener.onReceiveMessage(message); } }, onReceiveStatus: (status) => { - this.trace("Received status from child [" + child.getCallNumber() + "]"); + if (this.traceEnabled) { + this.trace("Received status from child [" + child.getCallNumber() + "]"); + } if (!receivedMetadata && previousAttempts > 0) { status.metadata.set(PREVIONS_RPC_ATTEMPTS_METADATA_KEY, `${previousAttempts}`); } @@ -66451,7 +66645,9 @@ var require_retrying_call = __commonJS({ }, bufferEntry.message.message); const nextEntry = this.getBufferEntry(messageIndex + 1); if (nextEntry.entryType === "HALF_CLOSE") { - this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message"); + if (this.traceEnabled) { + this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message"); + } childCall.nextMessageToSend += 1; childCall.call.halfClose(); } @@ -66466,7 +66662,9 @@ var require_retrying_call = __commonJS({ } } sendMessageWithContext(context3, message) { - this.trace("write() called with message of length " + message.length); + if (this.traceEnabled) { + this.trace("write() called with message of length " + message.length); + } const writeObj = { message, flags: context3.flags @@ -66527,7 +66725,9 @@ var require_retrying_call = __commonJS({ for (const call of this.underlyingCalls) { if ((call === null || call === void 0 ? void 0 : call.state) === "ACTIVE") { if (call.nextMessageToSend === halfCloseIndex || call.nextMessageToSend === halfCloseIndex - 1) { - this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent"); + if (this.traceEnabled) { + this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent"); + } call.nextMessageToSend += 1; call.call.halfClose(); } @@ -66757,7 +66957,7 @@ var require_internal_channel = __commonJS({ this.connectivityState = connectivity_state_1.ConnectivityState.IDLE; this.currentPicker = new picker_1.UnavailablePicker(); this.configSelectionQueue = []; - this.pickQueue = []; + this.pickQueue = /* @__PURE__ */ new Set(); this.connectivityStateWatchers = []; this.callRefTimer = null; this.configSelector = null; @@ -66824,9 +67024,9 @@ var require_internal_channel = __commonJS({ }, updateState: (connectivityState, picker) => { this.currentPicker = picker; - const queueCopy = this.pickQueue.slice(); - this.pickQueue = []; - if (queueCopy.length > 0) { + const queueCopy = this.pickQueue; + this.pickQueue = /* @__PURE__ */ new Set(); + if (queueCopy.size > 0) { this.callRefTimerUnref(); } for (const call of queueCopy) { @@ -66893,15 +67093,22 @@ var require_internal_channel = __commonJS({ this.filterStackFactory = new filter_stack_1.FilterStackFactory([ new compression_filter_1.CompressionFilterFactory(this, this.options) ]); - this.trace("Channel constructed with options " + JSON.stringify(options, void 0, 2)); - const error2 = new Error(); + if (this.traceEnabled) { + this.trace("Channel constructed with options " + JSON.stringify(options, void 0, 2)); + } if ((0, logging_1.isTracerEnabled)("channel_stacktrace")) { + const error2 = new Error(); (0, logging_1.trace)(constants_1.LogVerbosity.DEBUG, "channel_stacktrace", "(" + this.channelzRef.id + ") Channel constructed \n" + ((_f = error2.stack) === null || _f === void 0 ? void 0 : _f.substring(error2.stack.indexOf("\n") + 1))); } this.lastActivityTimestamp = /* @__PURE__ */ new Date(); } + get traceEnabled() { + return (0, logging_1.isTracerEnabled)("channel"); + } trace(text, verbosityOverride) { - (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text); + if (this.traceEnabled) { + (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text); + } } callRefTimerRef() { var _a, _b, _c, _d; @@ -66910,14 +67117,18 @@ var require_internal_channel = __commonJS({ }, MAX_TIMEOUT_TIME); } if (!((_b = (_a = this.callRefTimer).hasRef) === null || _b === void 0 ? void 0 : _b.call(_a))) { - this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length); + if (this.traceEnabled) { + this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size); + } (_d = (_c = this.callRefTimer).ref) === null || _d === void 0 ? void 0 : _d.call(_c); } } callRefTimerUnref() { var _a, _b, _c; if (!((_a = this.callRefTimer) === null || _a === void 0 ? void 0 : _a.hasRef) || this.callRefTimer.hasRef()) { - this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length); + if (this.traceEnabled) { + this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size); + } (_c = (_b = this.callRefTimer) === null || _b === void 0 ? void 0 : _b.unref) === null || _c === void 0 ? void 0 : _c.call(_b); } } @@ -66969,9 +67180,15 @@ var require_internal_channel = __commonJS({ }); } queueCallForPick(call) { - this.pickQueue.push(call); + this.pickQueue.add(call); this.callRefTimerRef(); } + removeCallFromPickQueue(call) { + this.pickQueue.delete(call); + if (this.pickQueue.size === 0) { + this.callRefTimerUnref(); + } + } getConfig(method, metadata) { if (this.connectivityState !== connectivity_state_1.ConnectivityState.SHUTDOWN) { this.resolvingLoadBalancer.exitIdle(); @@ -67052,19 +67269,25 @@ var require_internal_channel = __commonJS({ this.lastActivityTimestamp = /* @__PURE__ */ new Date(); this.maybeStartIdleTimer(); } - createLoadBalancingCall(callConfig, method, host, credentials, deadline) { - const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createLoadBalancingCall [" + callNumber + '] method="' + method + '"'); - return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, callNumber); + createLoadBalancingCall(callConfig, method, host, credentials, deadline, callNumber) { + const finalCallNumber = callNumber !== null && callNumber !== void 0 ? callNumber : (0, call_number_1.getNextCallNumber)(); + if (this.traceEnabled) { + this.trace("createLoadBalancingCall [" + finalCallNumber + '] method="' + method + '"'); + } + return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber); } - createRetryingCall(callConfig, method, host, credentials, deadline) { - const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createRetryingCall [" + callNumber + '] method="' + method + '"'); - return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget())); + createRetryingCall(callConfig, method, host, credentials, deadline, callNumber) { + const finalCallNumber = callNumber !== null && callNumber !== void 0 ? callNumber : (0, call_number_1.getNextCallNumber)(); + if (this.traceEnabled) { + this.trace("createRetryingCall [" + finalCallNumber + '] method="' + method + '"'); + } + return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget())); } createResolvingCall(method, deadline, host, parentCall, propagateFlags) { const callNumber = (0, call_number_1.getNextCallNumber)(); - this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline)); + if (this.traceEnabled) { + this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline)); + } const finalOptions = { deadline, flags: propagateFlags !== null && propagateFlags !== void 0 ? propagateFlags : constants_1.Propagate.DEFAULTS, @@ -67090,7 +67313,7 @@ var require_internal_channel = __commonJS({ for (const call of this.pickQueue) { call.cancelWithStatus(constants_1.Status.UNAVAILABLE, "Channel closed before call started"); } - this.pickQueue = []; + this.pickQueue.clear(); if (this.callRefTimer) { clearInterval(this.callRefTimer); } @@ -68798,15 +69021,17 @@ var require_server_interceptors = __commonJS({ } getAuthContext() { var _a; - if (((_a = this.stream.session) === null || _a === void 0 ? void 0 : _a.socket) instanceof tls_1.TLSSocket) { - const peerCertificate = this.stream.session.socket.getPeerCertificate(); - return { - transportSecurityType: "ssl", - sslPeerCertificate: peerCertificate.raw ? peerCertificate : void 0 - }; - } else { + if (!(((_a = this.stream.session) === null || _a === void 0 ? void 0 : _a.socket) instanceof tls_1.TLSSocket)) { return {}; } + if (!this.stream.session.socket.authorized) { + return {}; + } + const peerCertificate = this.stream.session.socket.getPeerCertificate(); + return { + transportSecurityType: "ssl", + sslPeerCertificate: peerCertificate.raw ? peerCertificate : void 0 + }; } getConnectionInfo() { return this.connectionInfo; @@ -68888,6 +69113,7 @@ var require_server2 = __commonJS({ var uri_parser_1 = require_uri_parser(); var channelz_1 = require_channelz(); var server_interceptors_1 = require_server_interceptors(); + var environment_1 = require_environment(); var UNLIMITED_CONNECTION_AGE_MS = ~(1 << 31); var KEEPALIVE_MAX_TIME_MS = ~(1 << 31); var KEEPALIVE_TIMEOUT_MS = 2e4; @@ -70141,9 +70367,15 @@ var require_server2 = __commonJS({ try { handler2.func(stream2, respond); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -70177,9 +70409,15 @@ var require_server2 = __commonJS({ try { handler2.func(stream2, respond); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -70233,9 +70471,15 @@ var require_server2 = __commonJS({ try { handler2.func(stream2); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); } @@ -70257,9 +70501,15 @@ var require_server2 = __commonJS({ try { handler2.func(stream2); } catch (err) { + let details; + if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) { + details = `Server method handler threw error ${err.message}`; + } else { + details = "Unknown error"; + } call.sendStatus({ code: constants_1.Status.UNKNOWN, - details: `Server method handler threw error ${err.message}`, + details, metadata: null }); }