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

Fixed loss of "this" identifier inside callMiddlewareInterceptor. #1320

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DonVietnam
Copy link
Contributor

@DonVietnam DonVietnam commented Mar 4, 2025

📝 Description

When adding a solution for the problem of losing context when using call middleware in pull request #1270, a bug was made that leads to the loss of the "this" identifier inside the middleware wrapped by interceptors. To solve this problem, the code of the interceptCallMiddleware method was reworked so that it returns a ordinary function instead of an arrow function, which will later allow it to be correctly executed from call methods to preserve the "this" identifier.

The necessary tests were added.

🎯 Relevant issues

#1317

💎 Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

🚦 How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Integration middlware test "Test hook middleware interceptors".
  • Unit service broker test "Test broker.interceptCallMiddleware".

🏁 Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

Two unit tests failed for me locally both before and after my changes:

  • Test EncryptionMiddleware › should decrypt data with IV
  • Test EncryptionMiddleware › should encrypt the data

Sorry, something went wrong.

Copy link

pkg-pr-new bot commented Mar 4, 2025

Open in Stackblitz

npm i https://pkg.pr.new/moleculerjs/moleculer@1320

commit: a2c3f4e

@DonVietnam
Copy link
Contributor Author

@Tstassin FYI

@Tstassin
Copy link

Tstassin commented Mar 26, 2025

@icebob when could you release this ? It's blocking on our side, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants