Please answer the following questions for yourself before submitting an issue.
[x] I am running the latest version
[x] I checked the documentation and found no answer
[x] I checked to make sure that this issue has not already been filed
[x] I'm reporting the issue to the correct repository
Current Behavior
When awaiting a ctx.emit call, the promise wait for the event to be completed locally but will resolve as soon as the event is sent on the transit when sent remotely.
A workaround for now is to remove the await but if the emit is wrapped by a middleware, it prevents it to be async.
I would expect to have a consistent behavior for both cases. I'd say I'd expect the local event to not wait for completion (matching the remote behavior).
Note: It could break tests with events that relies on this behavior.
:stop_sign: Do you want to ask a question ?
Please head to the Discord chat
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
When awaiting a
ctx.emit
call, the promise wait for the event to be completed locally but will resolve as soon as the event is sent on the transit when sent remotely.A workaround for now is to remove the await but if the
emit
is wrapped by a middleware, it prevents it to be async.This can be found here:
https://github.com/moleculerjs/moleculer/blob/1fa2440279ec8f242399e1f3dea30abead7c66e0/src/service-broker.js#L1357-L1389
Expected Behavior
I would expect to have a consistent behavior for both cases. I'd say I'd expect the local event to not wait for completion (matching the remote behavior).
Note: It could break tests with events that relies on this behavior.
Failure Information
Reproduce code snippet
Gives an output like this:
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.