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 · 2 comments

Comments

@XGHeaven
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

@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

This comment has been minimized.

Copy link
Member

commented Apr 21, 2018

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

@kamilmysliwiec

This comment has been minimized.

Copy link
Member

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
Projects
None yet
2 participants
You can’t perform that action at this time.