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

fix(core): process exit before shutdown hook end #10696

Conversation

kos984
Copy link

@kos984 kos984 commented Dec 12, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

Apollo server has own process listener which used in NestJS graphql https://unpkg.com/browse/[email protected]/src/ApolloServer.ts
NestJs implementation https://github.com/nestjs/nest/blob/master/packages/core/nest-application-context.ts#L308
so both libs listen SIGINT code and NestJs just after start remove own listeners and then start waiting promise results, in same time event loop go to Apollo handler and just after Apollo server is down it send process.kill event, but NestJs already removed own handler, so app close without wait all promises inited by NestJs

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build 81e9f04b-5c3e-4765-9ee0-a8b4ea7fea5b

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.404%

Totals Coverage Status
Change from base Build abe177fe-1d62-4ed4-af04-4b399e9297fe: 0.0%
Covered Lines: 6202
Relevant Lines: 6640

💛 - Coveralls

@micalevisk
Copy link
Member

micalevisk commented Dec 15, 2022

could you please see if this change will solve the bug nestjs/nest-cli#1614

@kos984
Copy link
Author

kos984 commented Dec 15, 2022

@micalevisk I am not able reproduce it on my mac, I see hook is not ending but have not issue with port.
I see after adding my fix shutdown hook will work correct and complete before new app starts
you can check your case for example by editing

/node_modules/@nestjs/core/nest-application-context.js

it just few lines of code

@micalevisk
Copy link
Member

yeah, it didn't solved that issue :/

@kamilmysliwiec
Copy link
Member

lgtm

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

Successfully merging this pull request may close these issues.

4 participants