Better reporting for DB corruption errors

This commit is contained in:
Fedor Indutny 2021-10-21 13:13:33 -07:00 committed by GitHub
parent 092c2fd0d7
commit 1b1ed2cd05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 5 deletions

View file

@ -19,10 +19,17 @@ const port = parentPort;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function respond(seq: number, error: Error | undefined, response?: any) {
const corruptionLog = db.getCorruptionLog();
const errorMessage = [
...(error ? [error.stack] : []),
...(corruptionLog ? [corruptionLog] : []),
].join('\n');
const wrappedResponse: WrappedWorkerResponse = {
type: 'response',
seq,
error: error ? error.stack : undefined,
error: errorMessage,
response,
};
port.postMessage(wrappedResponse);