-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
In request scoped event handlers, it seems misleading to register the event payload as the request, while not getting the context id from that same object.
As seen in the loader here:
event-emitter/lib/event-subscribers.loader.ts
Line 143 in 8690130
| >({ payload: request }); |
The ContextIdFactory is not given a fair chance to check if the event already has a context id (because it get's nested in {payload: request} ), so a new context id is created every time.
The result of this is the event payload doesn't get synced to the REQUEST_CONTEXT_ID, meanwhile it gets registered by nest as the request. This means that downstream systems can't inject the request and leverage the context id to load new dependencies into the tree.
Describe the solution you'd like
I'd propose changing from
ContextIdFactory.getByRequest<EventPayloadHost>({ payload: request });
to
ContextIdFactory.getByRequest<EventPayloadHost>(request);
but i'm unsure of the original justification for nesting it
Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
leveraging the request to and the injector to load new dependencies into an existing tree