sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Sentry treats all Injectable's with `use` function as middleware

Open asomethings opened this issue 6 months ago • 1 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

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

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)

asomethings avatar Aug 28 '24 13:08 asomethings