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

regression ? In middleware call(next) hook: 'this' is now undefined in v0.14.33+ #1317

Open
Tstassin opened this issue Jan 23, 2025 · 0 comments

Comments

@Tstassin
Copy link

  • I am trying to upgrade from 0.14.32 to 0.14.33+
  • 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

In MoleculerJS version 0.14.33+, the call(next) middleware hook no longer has access to the this context. In previous versions (e.g., 0.14.32), this inside the call(next) hook referred to the broker instance, which was useful for accessing broker-level properties like nodeID or logging functionalities.

Upon investigation, it seems this regression may have been introduced by the changes in Pull Request #1270, which adjusted the context binding in certain hooks. While this change likely aimed to address other issues, it inadvertently broke access to this in the call(next) hook.

Expected Behavior

I can access broker using 'this' in a call(next) hook

Steps to Reproduce

Using this codesandbox : https://codesandbox.io/p/devbox/moleculer-sample-forked-p4hjmx

Switch between versions 0.14.32 and 0.14.33 in package.json, npm iand see that with 0.14.32 it logs myNodeand with 0.14.33 it logs undefined

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

No branches or pull requests

1 participant