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

Unhandled promise rejections during MongooseModule initialization #1057

Open
1 of 2 tasks
ukito-pl opened this issue Oct 8, 2021 · 4 comments
Open
1 of 2 tasks

Unhandled promise rejections during MongooseModule initialization #1057

ukito-pl opened this issue Oct 8, 2021 · 4 comments

Comments

@ukito-pl
Copy link

ukito-pl commented Oct 8, 2021

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

No response

Versions

8.0.1 -> 9.0.0

Describe the regression

Hi,
I recently upgraded @nestjs/mongoose to 9.0.0 and mongoose to 6.0.9.

Since then mongoose errors are not being caught. If there is any exception being thrown during establishing connection it results in unhandled promise rejection. In the snippet below I set retryAttempts to 10, but there is unhandled promise rejection after 1st failed connection attempt and there are no further attempts.

Minimum reproduction code

@Module({
  imports: [
    MongooseModule.forRoot(
      'mongodb://user:pass@localhost:27020/main?authSource=admin',
      { retryAttempts: 10 },
    ),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Here is full reproduction repository: https://github.com/ukito-pl/nest-mongoose-bug

Expected behavior

I expect that in case of connection error Mongoose will retry connection according to 'retryAttempts' option and will not cause unhandled promise rejections.

Other

No response

@kamilmysliwiec
Copy link
Member

Please provide a minimum reproduction repository as a Github repository.

@ukito-pl
Copy link
Author

Here is github repo: https://github.com/ukito-pl/nest-mongoose-bug

@gsaint
Copy link

gsaint commented Dec 8, 2021

Having the same issue here!

@jordanberry
Copy link

Experiencing the same, happy to help triage - appreciate the great framework 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants