mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) restore ActiveDoc shutdown behavior on error
Summary: A recent change perturbed some error handling when an ActiveDoc is shutting down. It is important that errors get thrown when attempting to replace a non-existent document. My bad in review for not catching. Test Plan: Snapshot test passes again Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian, cyprien Differential Revision: https://phab.getgrist.com/D3824
This commit is contained in:
parent
1ff93f89c2
commit
391d39effc
@ -34,7 +34,7 @@ import {
|
|||||||
TransformRule
|
TransformRule
|
||||||
} from 'app/common/ActiveDocAPI';
|
} from 'app/common/ActiveDocAPI';
|
||||||
import {ApiError} from 'app/common/ApiError';
|
import {ApiError} from 'app/common/ApiError';
|
||||||
import {asyncOnce, mapGetOrSet, MapWithTTL} from 'app/common/AsyncCreate';
|
import {mapGetOrSet, MapWithTTL} from 'app/common/AsyncCreate';
|
||||||
import {AttachmentColumns, gatherAttachmentIds, getAttachmentColumns} from 'app/common/AttachmentColumns';
|
import {AttachmentColumns, gatherAttachmentIds, getAttachmentColumns} from 'app/common/AttachmentColumns';
|
||||||
import {
|
import {
|
||||||
BulkAddRecord,
|
BulkAddRecord,
|
||||||
@ -231,10 +231,7 @@ export class ActiveDoc extends EventEmitter {
|
|||||||
private _recoveryMode: boolean = false;
|
private _recoveryMode: boolean = false;
|
||||||
private _shuttingDown: boolean = false;
|
private _shuttingDown: boolean = false;
|
||||||
private _afterShutdownCallback?: () => Promise<void>;
|
private _afterShutdownCallback?: () => Promise<void>;
|
||||||
// catch & report error so that asyncOnce does not get cleared.
|
private _doShutdown?: Promise<void>;
|
||||||
private _doShutdown = asyncOnce(
|
|
||||||
() => this._doShutdownImpl().catch((e) => log.error('Uncaught shutdown error', e))
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In cases where large numbers of documents are restarted simultaneously
|
* In cases where large numbers of documents are restarted simultaneously
|
||||||
@ -501,10 +498,10 @@ export class ActiveDoc extends EventEmitter {
|
|||||||
if (options.afterShutdown) {
|
if (options.afterShutdown) {
|
||||||
this._afterShutdownCallback = options.afterShutdown;
|
this._afterShutdownCallback = options.afterShutdown;
|
||||||
}
|
}
|
||||||
await this._doShutdown();
|
this._doShutdown ||= this._doShutdownImpl();
|
||||||
|
await this._doShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async _doShutdownImpl(): Promise<void> {
|
private async _doShutdownImpl(): Promise<void> {
|
||||||
const docSession = makeExceptionalDocSession('system');
|
const docSession = makeExceptionalDocSession('system');
|
||||||
this._log.debug(docSession, "shutdown starting");
|
this._log.debug(docSession, "shutdown starting");
|
||||||
|
Loading…
Reference in New Issue
Block a user