Skip to content

Commit

Permalink
Fix bug in schemaReporter.ts where stop() called while sendOneReportA…
Browse files Browse the repository at this point in the history
…ndScheduleNext() is suspended would still result in setTimeout() being called. (#5222)
  • Loading branch information
sachindshinde committed May 18, 2021
1 parent 9e1bf7d commit a43c411
Showing 1 changed file with 13 additions and 9 deletions.
Expand Up @@ -117,11 +117,13 @@ export class SchemaReporter {
const result = await this.reportServerInfo(sendNextWithExecutableSchema);
switch (result.kind) {
case 'next':
this.pollTimer = setTimeout(
() =>
this.sendOneReportAndScheduleNext(result.withExecutableSchema),
result.inSeconds * 1000,
);
if (!this.stopped()) {
this.pollTimer = setTimeout(
() =>
this.sendOneReportAndScheduleNext(result.withExecutableSchema),
result.inSeconds * 1000,
);
}
return;
case 'stop':
return;
Expand All @@ -133,10 +135,12 @@ export class SchemaReporter {
this.logger.error(
`Error reporting server info to Apollo during schema reporting: ${error}`,
);
this.pollTimer = setTimeout(
() => this.sendOneReportAndScheduleNext(false),
this.fallbackReportingDelayInMs,
);
if (!this.stopped()) {
this.pollTimer = setTimeout(
() => this.sendOneReportAndScheduleNext(false),
this.fallbackReportingDelayInMs,
);
}
}
}

Expand Down

0 comments on commit a43c411

Please sign in to comment.