gristlabs_grist-core/app/server/lib/NullSandbox.ts
Dmitry S 8da89b0a3d (core) Improve behavior to update current time, to allow inactive docs to shut down, and reduce spurious errors.
Summary:
- When sandbox is down, report failing UpdateCurrentTime calls as warnings instead of errors.
- When applying system actions (such as updating current time), don't treat
  them as user activity for the purpose of keeping the doc open.

Test Plan: Added a test case for the fixed behavior.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4324
2024-08-29 01:22:57 -04:00

28 lines
702 B
TypeScript

import {ISandbox} from 'app/server/lib/ISandbox';
export class UnavailableSandboxMethodError extends Error {
constructor(message: string) {
super(message);
}
}
export class NullSandbox implements ISandbox {
public async shutdown(): Promise<unknown> {
throw new UnavailableSandboxMethodError('shutdown is not available');
}
public async pyCall(_funcName: string, ..._varArgs: unknown[]) {
throw new UnavailableSandboxMethodError('pyCall is not available');
}
public async reportMemoryUsage() {
throw new UnavailableSandboxMethodError('reportMemoryUsage is not available');
}
public getFlavor() {
return 'null';
}
public isProcessDown() { return true; }
}