Replies: 1 comment 8 replies
-
I need to see a reproduction, logs are not reproduction. Also the first step should be finding out the full stack trace as without it this error is not telling us anything. Maybe look at this example project (which works just fine) and compare what you do differently. https://github.com/mikro-orm/nestjs-realworld-example-app And as usual, consult the upgrading guides in detail. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
upgrade from v4 to v5 and v6 and this issue is present in both v5 and v6. I have isolated to my imported modules. How can i further isolate to identify what is causing this?
For reference my appmodule
@Module({ controllers: [AppController], imports: [ ConfigModule.forRoot({ envFilePath: ['.env','.env.local','.env.deployment'], isGlobal: true, }), ConsoleModule, MikroOrmModule.forRoot(), ScheduleModule.forRoot(), SentryModule.forRootAsync({ imports: [SharedModule,ConfigModule], inject: [ConfigService], useFactory: async (configService: ConfigService) => ({ enabled: configService.get<boolean>("SENTRY_ENABLED"), dsn: configService.get<string>("SENTRY_DSN"), debug: configService.get<boolean>("SENTRY_DEBUG"), environment: configService.get<string>("NODE_ENV"), release: null, // must create a release in sentry.io dashboard logLevels: ['debug'] //LogLevel.Error, //based on sentry.io loglevel // }), }), BullModule.forRootAsync({ imports: [SharedModule, ConfigModule], useFactory: async (configService: ConfigService) => ({ redis: { host: configService.get<string>("REDIS_SERVER_HOST"), port: configService.get<number>("REDIS_SERVER_PORT"), db: configService.get<number>("REDIS_SERVER_DATABASE"), password: configService.get<string>("REDIS_SERVER_PASSWORD"), }, }), inject: [ConfigService], }), LoggerModule.forRootAsync({ inject: [ConfigService], useFactory: async (configService: ConfigService) => { return { pinoHttp: configService.get<any> ? { level: "debug", transport : { target: "pino-pretty", //new (after error resolve)refer here https://stackoverflow.com/questions/71649204/pinowarning-prettyprint-is-deprecated-look-at-https-github-com-pinojs-pino-p options:{ colorize: true, levelFirst: true, translateTime: "UTC:mm/dd/yyyy, h:MM:ss TT Z", }, } } : {}, }; }, imports: [ConfigModule], // providers: undefined }), AwsSdkModule.forRootAsync({ // TODO get rid off fallback env variables (added for correct work in local env) defaultServiceOptions: { useFactory: (configService: ConfigService) => ({ credentials: { accessKeyId: configService.get<string>("AWS_SDK_ACCESS_KEY") || configService.get<string>("MINIO_ACCESS_KEY"), secretAccessKey: configService.get<string>("AWS_SDK_SECRET_KEY") || configService.get<string>("MINIO_SECRET_KEY"), }, region: configService.get<string>("S3_STORAGE_REGION") || null, endpoint: configService.get<string>("S3_STORAGE_ENDPOINT_PRIVATE") || null, signatureVersion: "v4", s3ForcePathStyle: true, // false value not compatible with MinIO }), inject: [ConfigService], imports: [SharedModule,ConfigModule], }, }), paymentsModule, SlackUserModule, OrganisationModule, DashboardModule, NestAsyncEventModule, SharedModule, UsageStatsModule, UserModule, MailingModule, CategoryModule, AuthModule, PostModule, InboxModule, MessagingModule, NotificationModule, DataModule, ], providers: [ConfigService] }) export class AppModule { configure(consumer: MiddlewareConsumer) { consumer.apply(LogsMiddleware).forRoutes('*'); } }
And my authmodule:
@Module({ imports: [ JwtModule.registerAsync({ imports: [ConfigModule], inject: [ConfigService], useFactory: (configService: ConfigService) => ({ secretOrPrivateKey: configService.get<string>("JWT_SECRET_KEY"), signOptions: { expiresIn: configService.get<number>("JWT_EXPIRATION_TIME"), }, }), }), MikroOrmModule.forFeature({ entities: [...Object.values(moduleEntities), User] }), forwardRef(() => UserModule), // ConfigService, NestAsyncEventModule, PassportModule.register({ defaultStrategy: "jwt" }), ], providers: [AuthService, BannedByIpService, JwtStrategy, ConfigService], controllers: Object.values(authControllers), exports: [JwtStrategy, PassportModule, AuthService, BannedByIpService], }) export class AuthModule {}
Reproduction
upgrade from v4 to v5 and v6 and this issue is present in both v5 and v6. Once upgraded and you try and run the application, the application throws an error for entity discovery as per below:
[Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [MikroORM] [info] MikroORM version: 6.2.5 [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [MikroORM] [discovery] ORM entity discovery started, using TsMorphMetadataProvider [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] MikroOrmModule dependencies initialized +25ms [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] SentryModule dependencies initialized +1ms [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] PassportModule dependencies initialized +1ms [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] HttpModule dependencies initialized +4ms [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] HttpModule dependencies initialized +1ms [Nest] 30312 - 09/05/2024, 2:07:17 pm LOG [InstanceLoader] ConfigHostModule dependencies initialized +3ms [Nest] 30312 - 09/05/2024, 2:07:17 pm ERROR [ExceptionHandler] Cannot read properties of undefined (reading 'values') TypeError: Cannot read properties of undefined (reading 'values')
What driver are you using?
@mikro-orm/postgresql
MikroORM version
6
Node.js version
node.js version 20
Operating system
windows, linux
Validations
Beta Was this translation helpful? Give feedback.
All reactions