-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Issue Description
In the NATS broker implementation, there's a critical bug in the publishMessage
method where client.publish()
is treated as a Promise in a Promise.race()
construction.
File: src/auth-service/utils/messaging/brokers/nats-broker.js
Problem:
The @nats/js
's publish()
method returns void
(not a Promise). When treating it as a promise with Promise.race()
, publishPromise
resolves immediately as undefined
, and the timeout branch will always win – raising a false "timed-out" error on every call.
Impact:
This will mark the broker as unhealthy and trigger unnecessary fail-over to other message brokers, degrading performance and potentially causing message delivery issues.
Proposed Solutions
Either:
- Await the flush operation instead:
this.client.publish(topic, payloadBuf);
await this.client.flush();
- Remove the
Promise.race
and rely on the library's internal back-pressure.
References
- Discovered in PR review: Add message broker redundancy to authentication service #4716 (comment)
Metadata
Metadata
Assignees
Labels
No labels