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

XGHeaven opened this issue Apr 17, 2018 · 2 comments


Copy link

commented Apr 17, 2018

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

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

(async () => {
  const app = await NestFactory.create(AppModule)
  await app.listen(3000)

current log

before init
after init

Expected behavior

should log

before init
after init

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?


Nest version: 4.6.6

For Tooling issues:

  • Node version: 8.11.1
  • Platform: Mac

This comment has been minimized.

Copy link

commented Apr 21, 2018

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


This comment has been minimized.

Copy link

commented Apr 22, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.