Skip to content

apollo-server-core: Fix delayed shutdown bug in schemaReporter.ts#5222

Merged
glasser merged 1 commit into
mainfrom
sachin/fix-delayed-shutdown-bug-schema-reporting
May 18, 2021
Merged

apollo-server-core: Fix delayed shutdown bug in schemaReporter.ts#5222
glasser merged 1 commit into
mainfrom
sachin/fix-delayed-shutdown-bug-schema-reporting

Conversation

@sachindshinde

Copy link
Copy Markdown
Contributor

In this PR, schemaReporter.ts is changed to fix a bug where calling stop() may not prevent functions from being executed in the future via setTimeout(). The specific case is when:

  1. sendOneReportAndScheduleNext() is suspended while waiting on a response from Studio.
  2. stop() is called and finishes execution.
  3. sendOneReportAndScheduleNext() resumes execution, and calls setTimeout() to schedule another invocation of sendOneReportAndScheduleNext() some time in the future (usually 60 seconds).
  4. sendOneReportAndScheduleNext() executes in the future, but early-returns because it checks this.isStopped().

The end result is Node being prevented from clean shutdown for ~60 seconds in such cases.

…ndScheduleNext() is suspended would still result in setTimeout() being called.
@glasser glasser merged commit a43c411 into main May 18, 2021
@glasser glasser deleted the sachin/fix-delayed-shutdown-bug-schema-reporting branch May 18, 2021 22:49
glasser added a commit that referenced this pull request May 18, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants