You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zhaohai666 (via GitHub)" <gi...@apache.org> on 2026/09/15 03:44:10 UTC
[PR] fix(nodejs): transport layer self-healing and logger close deferral [rocketmq-clients]
zhaohai666 opened a new pull request, #1375:
URL: https://github.com/apache/rocketmq-clients/pull/1375
P3 fix(nodejs): transport layer self-healing and logger close deferral
- `Endpoints.getGrpcTarget()`: prefix the gRPC target with the resolver scheme —
`ipv4:` / `ipv6:` (bracketed IPv6 hosts) / `dns:` — so grpc-js resolves multi-address
and bare-IPv6 targets correctly.
- `RpcClientManager`: key rpc clients by the `endpoints.facade` **string** instead of
object identity (endpoints are recreated on every route fetch, leaking duplicate
channels); add `evict()`.
- `RpcClient`: keepalive (5 min / 30 s + `keepalive_permit_without_calls`) and max
message size channel options.
- `BaseClient` heartbeat: rejoin isolated endpoints after success; after ≥ 2 consecutive
failures rebuild the transport (evict stale `RpcClient` + refresh telemetry session),
throttled by a 30 s per-endpoints cooldown.
- Verify-message command replies with `VerifyMessageResult` (nonce) instead of echoing
the command.
- `logger.close()` deferred to the next macrotask (`setImmediate`) so subclass shutdown
logs no longer throw `log stream had been closed`.
**Tests:** `nodejs/test/route/Endpoints.test.ts` (4 cases, offline, all pass)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(nodejs): transport layer self-healing and logger close deferral [rocketmq-clients]
Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin merged PR #1375:
URL: https://github.com/apache/rocketmq-clients/pull/1375
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(nodejs): transport layer self-healing and logger close deferral [rocketmq-clients]
Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on code in PR #1375:
URL: https://github.com/apache/rocketmq-clients/pull/1375#discussion_r4012297443
##########
nodejs/src/client/BaseClient.ts:
##########
@@ -512,23 +575,54 @@ export abstract class BaseClient {
const obj = command.toObject();
this.logger.warn('Ignore verify message command from remote, which is not expected, clientId=%s, command=%j',
this.clientId, obj);
+ // Respond with VerifyMessageResult carrying the same nonce, mirroring the Java
+ // client (BaseClient#onVerifyMessageCommand), instead of echoing the command.
const telemetryCommand = new TelemetryCommand();
telemetryCommand.setStatus(new Status().setCode(Code.NOT_IMPLEMENTED));
- telemetryCommand.setVerifyMessageCommand(new VerifyMessageCommand().setNonce(obj.nonce));
+ telemetryCommand.setVerifyMessageResult(new VerifyMessageResult().setNonce(obj.nonce));
this.telemetry(endpoints, telemetryCommand);
}
onPrintThreadStackTraceCommand(endpoints: Endpoints, command: PrintThreadStackTraceCommand) {
const obj = command.toObject();
- this.logger.warn('Ignore orphaned transaction recovery command from remote, which is not expected, clientId=%s, command=%j',
+ this.logger.info('Received print thread stack trace command from remote, clientId=%s, command=%j',
this.clientId, obj);
- const nonce = obj.nonce;
const telemetryCommand = new TelemetryCommand();
- telemetryCommand.setThreadStackTrace(new ThreadStackTrace().setThreadStackTrace('mock stack').setNonce(nonce));
+ telemetryCommand.setThreadStackTrace(new ThreadStackTrace()
+ .setThreadStackTrace(this.#buildProcessDiagnostics())
+ .setNonce(obj.nonce));
telemetryCommand.setStatus(new Status().setCode(Code.OK));
this.telemetry(endpoints, telemetryCommand);
}
+ /**
+ * Build Node.js process diagnostics in place of Java-style thread stack traces.
+ * Java sends per-thread stacks via ThreadMXBean; Node.js is single-threaded per
+ * process, so we expose the closest equivalent runtime snapshot.
Review Comment:
`_getActiveHandles()` is an undocumented Node.js internal API. The try/catch fallback is good defensive coding. Since this is best-effort diagnostics (not on a critical path), this is acceptable — just be aware it could break silently in future Node.js versions without notice.
##########
nodejs/src/route/Endpoints.ts:
##########
@@ -52,8 +52,27 @@ export class Endpoints {
this.facade = this.addressesList.map(addr => `${addr.host}:${addr.port}`).join(',');
}
+ /**
+ * gRPC target with resolver scheme prefix, mirroring the Java client:
+ * - IPv4 addresses: ipv4:127.0.0.1:10911,127.0.0.2:10912
+ * - IPv6 addresses: ipv6:[::1]:10911,[fe80::1]:10912 (brackets required by grpc-js)
+ * - Domain names: dns:example.com:8080,example.org:8081
+ */
getGrpcTarget() {
- return this.facade;
+ const targets = this.addressesList.map(addr => {
+ const host = this.scheme === AddressScheme.IPV6 ? `[${addr.host}]` : addr.host;
+ return `${host}:${addr.port}`;
+ }).join(',');
+ switch (this.scheme) {
+ case AddressScheme.IPV4:
+ return `ipv4:${targets}`;
Review Comment:
Good fix — adding the resolver scheme prefix (`ipv4:` / `ipv6:` / `dns:`) ensures grpc-js correctly handles multi-address and bare-IPv6 targets. This aligns with the Java client's `Endpoints.grpcTarget()` behavior. One thing to verify: ensure the RocketMQ Proxy's gRPC server accepts targets with these scheme prefixes. Standard grpc-js resolvers should handle them transparently, but worth confirming in integration tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org