Skip to content
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

Broker middleware call wrapper removes context data. Cannot use ctx.meta. #1241

Open
4 tasks done
ggondim opened this issue Sep 2, 2023 · 0 comments
Open
4 tasks done

Comments

@ggondim
Copy link

ggondim commented Sep 2, 2023

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • 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

  1. Create a call wrapper as a custom middleware exactly the way the official documentation indicates

image

  1. Use ctx.meta between actions, such as setting ctx.meta.$statusCode using moleculer-web

image

  1. 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.

  1. Git clone it
  2. npm install && npm run dev
  3. 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.

image

Context

  • Moleculer version: 0.14.31
  • NodeJS version: 19.7.0
  • Operating System: Ubuntu 22.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants