Skip to content

Commit a43c411

Browse files
Fix bug in schemaReporter.ts where stop() called while sendOneReportAndScheduleNext() is suspended would still result in setTimeout() being called. (#5222)
1 parent 9e1bf7d commit a43c411

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

packages/apollo-server-core/src/plugin/schemaReporting/schemaReporter.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ export class SchemaReporter {
117117
const result = await this.reportServerInfo(sendNextWithExecutableSchema);
118118
switch (result.kind) {
119119
case 'next':
120-
this.pollTimer = setTimeout(
121-
() =>
122-
this.sendOneReportAndScheduleNext(result.withExecutableSchema),
123-
result.inSeconds * 1000,
124-
);
120+
if (!this.stopped()) {
121+
this.pollTimer = setTimeout(
122+
() =>
123+
this.sendOneReportAndScheduleNext(result.withExecutableSchema),
124+
result.inSeconds * 1000,
125+
);
126+
}
125127
return;
126128
case 'stop':
127129
return;
@@ -133,10 +135,12 @@ export class SchemaReporter {
133135
this.logger.error(
134136
`Error reporting server info to Apollo during schema reporting: ${error}`,
135137
);
136-
this.pollTimer = setTimeout(
137-
() => this.sendOneReportAndScheduleNext(false),
138-
this.fallbackReportingDelayInMs,
139-
);
138+
if (!this.stopped()) {
139+
this.pollTimer = setTimeout(
140+
() => this.sendOneReportAndScheduleNext(false),
141+
this.fallbackReportingDelayInMs,
142+
);
143+
}
140144
}
141145
}
142146

0 commit comments

Comments
 (0)