Git Product home page Git Product logo

Comments (10)

uptownhr avatar uptownhr commented on July 30, 2024 2

@kachar thanks. I'll use this as a work around for the time being.

from nestjs-sentry.

kachar avatar kachar commented on July 30, 2024 1

One workaround is to use useValue: new SentryInterceptor() instead of useClass: SentryInterceptor but that's not very efficient

    {
      provide: APP_INTERCEPTOR,
-      useClass: SentryInterceptor,
+      useValue: new SentryInterceptor(),
    },

Better alternative might be to useFactory

    {
      provide: APP_INTERCEPTOR,
-      useClass: SentryInterceptor,
+      useFactory: () => new SentryInterceptor(),
    },

from nestjs-sentry.

kachar avatar kachar commented on July 30, 2024

I've ended up in the same scenario when trying to import SentryInterceptor

[Nest] 638883  - 09/21/2021, 11:45:51 AM     LOG [InstanceLoader] SentryModule dependencies initialized +143ms
[Nest] 638883  - 09/21/2021, 11:45:51 AM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the SentryInterceptor (?). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:
- If Object is a provider, is it part of the current AppModule?
- If Object is exported from a separate @Module, is that module imported within AppModule?
@Module({
imports: [ /* the Module containing Object */ ]
})

Error: Nest can't resolve dependencies of the SentryInterceptor (?). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:
- If Object is a provider, is it part of the current AppModule?
- If Object is exported from a separate @Module, is that module imported within AppModule?
@Module({
imports: [ /* the Module containing Object */ ]
})

A possible solution might be to add exports: [SentryInterceptor, GraphqlInterceptor] in sentry.module.ts

If that's a good way forward I'm up for creating a PR

from nestjs-sentry.

productdevbook avatar productdevbook commented on July 30, 2024

some problem how to fixed ?

from nestjs-sentry.

uptownhr avatar uptownhr commented on July 30, 2024

some problem how to fixed ?

use the useFactory instead of useClass as described above by kachar

from nestjs-sentry.

ntegral avatar ntegral commented on July 30, 2024

Thanks.. I'll update the documentation @uptownhr @productfrontenddeveloper @kachar

from nestjs-sentry.

boy51 avatar boy51 commented on July 30, 2024

One workaround is to use useValue: new SentryInterceptor() instead of useClass: SentryInterceptor but that's not very efficient

I think if we just use useValue nestjs will handle instantiation

providers: [
    {
      provide: APP_INTERCEPTOR,
      useValue: SentryInterceptor,
    },
  ],

from nestjs-sentry.

MichFe avatar MichFe commented on July 30, 2024

Hi all,

@ntegral I tested both useValue and useFactory. Seems that interceptor is not instanciated with useValue, working as expected with useFactory [Nestjs 7, lib 2.x.x].

from nestjs-sentry.

ntegral avatar ntegral commented on July 30, 2024

@MichFe Thanks for checking this.

from nestjs-sentry.

chiubaka avatar chiubaka commented on July 30, 2024

I'm seeing this with @nestjs/core v8.4.7 and @ntegral/nestjs-sentry v3.0.7 just by introducing the upgraded @ntegral/nestjs-sentry package into my repo.

from nestjs-sentry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.