Skip to content

Event Payload vs Request discrepancy #1622

@ColeStansbury

Description

@ColeStansbury

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:

>({ 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

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