Skip to content

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

Open
@Tstassin

Description

@Tstassin
  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions