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

Can support async life circle hook. #569

Closed
XGHeaven opened this issue Apr 17, 2018 · 3 comments
Closed

Can support async life circle hook. #569

XGHeaven opened this issue Apr 17, 2018 · 3 comments

Comments

@XGHeaven
Copy link

I'm submitting a...

[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

@Module({})
class AppModule implement OnModuleInit {
  async onModuleInit() {
    console.log('before init')
    await somePromise()
    console.log('after init')
  }
}

(async () => {
  console.log('before')
  const app = await NestFactory.create(AppModule)
  await app.listen(3000)
  console.log('after')
})()

current log

before
before init
after
after init

Expected behavior

should log

before
before init
after init
after

What is the motivation / use case for changing the behavior?

Sometimes, I write a few async bootstrap codes in onModuleInit. I want to wait for all of the codes in onModuleInit finished before listen. Can support async hook?

Environment

Nest version: 4.6.6

For Tooling issues:

  • Node version: 8.11.1
  • Platform: Mac
@kamilmysliwiec
Copy link
Member

This feature will be available in v5.0.0 major release. 🙂

@kamilmysliwiec
Copy link
Member

You can test it already using v5.0.0-beta.3 release

@lock
Copy link

lock bot commented Sep 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants