-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Nest-js instrumentation breaks @nestjs/event-emitter when using multiple @OnEvent on the same method #15218
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
Comments
Hey, thanks for writing in. We will look into it! |
Facing same issue. Using a custom decorator for multiple OnEvent like:
When used like Thanks @matthieuMay , I could've never guessed sentry sdk was causing it. How do you even debug something like this |
Hi, thanks for reminding us of this issue. cc @chargome I see you're already assigned but maybe you could take another look at this? Heass-up: Most team members are out for the rest of the week so might only get to it next week. If anyone has ideas how to fix this, PRs are also welcome :) |
Hi all I came up with a patch package but it is not perfect as all spans are merged into one span.
|
Facing same issue ~ |
@NiceChildHQ thanks for reporting, sorry this fell under the radar – contributions are welcome if anyone wants a go at this! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nestjs
SDK Version
8.52.0
Framework Version
Nestjs 10.4.7
Link to Sentry event
No response
Reproduction Example/SDK Setup
I set up a minimal repro here :
https://github.com/matthieuMay/sentry_nest_event_repro
This is a minimal nestjs + nestjs/event-emitter + sentry configuration.
It contains:
Steps to Reproduce
npm run start:dev
npm run start:dev
Expected Result
We should see the handler being called twice
Explanation of the bug
Nestjs initialize in two steps : first the decorators set metadata on the decorated functions and once all decorators have been read, this metadata is traducted in method modifications.
Sentry instrumentation overrides the OnEvent decorator in
SentryNestEventInstrumentation._createWrapOnEvent
method. This new decorator ovverides descriptor.value on every call.Therefore, when decorating the same handler with multiple @onevent, descriptor.value changes on every call changing the target of the metadata on every call. As a consequence, only the last called decorator is actually applied
Actual Result
The text was updated successfully, but these errors were encountered: