Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/beacon-node/src/monitoring/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export class MonitoringService {
}

/**
* Stop sending client stats
* Stop sending client stats and wait for any pending request to complete
*/
close(): void {
async close(): Promise<void> {
if (this.status === Status.Closed) return;
this.status = Status.Closed;

Expand All @@ -103,6 +103,7 @@ export class MonitoringService {
}
if (this.pendingRequest) {
this.fetchAbortController?.abort(FetchAbortReason.Close);
await this.pendingRequest;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/beacon-node/src/node/nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,12 @@ export class BeaconNode {
if (this.restApi) await this.restApi.close();
await this.network.close();
if (this.metricsServer) await this.metricsServer.close();
if (this.monitoring) this.monitoring.close();
if (this.monitoring) await this.monitoring.close();
await this.chain.persistToDisk();
await this.chain.close();
// Abort signal last: close() calls above clear intervals/timeouts so no new
// operations get scheduled. If we aborted first, a still-pending interval could
// fire and schedule a new operation after abort, leaving it stuck and delaying shutdown.
Comment thread
nflaig marked this conversation as resolved.
if (this.controller) this.controller.abort();
await sleep(DELAY_BEFORE_CLOSING_DB_MS);
await this.db.close();
Expand Down
Loading