moleculer
moleculer copied to clipboard
Broker middleware `call` wrapper removes context data. Cannot use ctx.meta.
Prerequisites
- [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 using a custom middleware in broker, specially when defing a call
wrapper exactly the way the official documentation indicates, context data appears to be removed.
For example, moleculer-web's context.meta.$statusCode
doesn't work when defining the middleware.
If you remove the middleware, everything works fine.
Expected Behavior
Context data should be there after calling the action.
moleculer-web's context.meta.$statusCode
should work even with middlewares.
Failure Information
Steps to Reproduce
- Create a
call
wrapper as a custom middleware exactly the way the official documentation indicates
- Use
ctx.meta
between actions, such as settingctx.meta.$statusCode
using moleculer-web
- Call the action, the context will be lost
Take a look at the repro steps below.
Reproduce code
Code is reproduced under this repro repo.
- Git clone it
-
npm install && npm run dev
-
curl --location 'localhost:4987/api/statusCodeTest/testNotFound' -I
You will see an HTTP 200 instead an HTTP 404 as defined in statusCode.service.ts
action.
Context
- Moleculer version:
0.14.31
- NodeJS version:
19.7.0
- Operating System:
Ubuntu 22.04