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

Sentry treats all Injectable's with use function as middleware #13507

Closed
3 tasks done
Tracked by #12504
asomethings opened this issue Aug 28, 2024 · 2 comments · Fixed by #13544
Closed
3 tasks done
Tracked by #12504

Sentry treats all Injectable's with use function as middleware #13507

asomethings opened this issue Aug 28, 2024 · 2 comments · Fixed by #13544
Assignees
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@asomethings
Copy link

asomethings commented Aug 28, 2024

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.27.0

Framework Version

Nest.js 10.4.1

Link to Sentry event

https://sentry.io/issues/5765154861/events/e100e2846c104bb293875be2fcc751c5/?project=4506504369405952

Reproduction Example/SDK Setup

StackBlitz

Create a Injectable class with use method

@Injectable()
export class SomeClass {
  async use(amount: number): Promise<number> {
     return amount - 1
  }
}

Steps to Reproduce

  1. Create a @Injectable() class with use method
  2. Try to use it from anywhere from the code
  3. TypeError: Cannot create proxy with a non-object as target or handler will be thrown

Expected Result

The function should be run normally without errors.

Actual Result

TypeError: Cannot create proxy with a non-object as target or handler will be thrown.

It seems it may apply to functions that sentry tries to proxy it (like transform / canActivate / intercept but not tested)

@github-actions github-actions bot added the Package: nestjs Issues related to the Sentry Nestjs SDK label Aug 28, 2024
@lforst
Copy link
Member

lforst commented Aug 28, 2024

@nicohrubec we should add guards to ensure that we only instrument when we can reasonably assume that we are actually in a middleware.

@nicohrubec
Copy link
Contributor

Hey @asomethings, thanks for writing in. I just opened a PR with a fix. Should be merged next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants