-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MoleculerRetryableError: Adapter not yet connected. Skipping publishing #83
Comments
I am experiencing the same behaviour. Did you come up with any solution @valeeum ? |
@FlavioF nope, unfortunately not. |
It seems like an internal race condition. The middleware is calling the adapter's connect() async function without waiting for it to be returned. The NATS adapter (which is what I use, but it's similar to other adapters), internally, expects that the connect() function finishes successfully (internally setting the connected field to true) as a pre-condition. I was able to monkey-patch it locally like this:
This effectively queues all published messages until the connection process succeeds or fails. One important thing to note here is that the emit/sendToChannel() must not be called/be awaited for during the service "started" function, as the internal connect() function of the adapter is called at a later point. I had to wrap my code with setImmediate() and that made everything work. |
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
When i call
this.broker.sendToChannel()
in my service started method, i get the following error:MoleculerRetryableError: Adapter not yet connected. Skipping publishing
In the snippet above, waiting 1 second after started is called creates an error. When I wait 10 seconds, i dont get this error.
I am using the latest version of the Redis adapter.
Expected Behavior
I expect the broker to wait until the connection is made before starting services.
The text was updated successfully, but these errors were encountered: