Skip to content

Commit e52a08d

Browse files
committed
Safely close file handle in all cases
1 parent 139c455 commit e52a08d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extensions/ql-vscode/src/common/logging/tee-logger.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ export class TeeLogger implements Logger, Disposable {
5858
} catch (e) {
5959
// Write an error message to the primary log, and stop trying to write to the side log.
6060
this.error = true;
61+
try {
62+
await this.fileHandle?.close();
63+
} catch (e) {
64+
void this.logger.log(
65+
`Failed to close file handle: ${getErrorMessage(e)}`,
66+
);
67+
}
6168
this.fileHandle = undefined;
6269
const errorMessage = getErrorMessage(e);
6370
await this.logger.log(
@@ -76,7 +83,13 @@ export class TeeLogger implements Logger, Disposable {
7683
}
7784

7885
dispose(): void {
79-
void this.fileHandle?.close();
86+
try {
87+
void this.fileHandle?.close();
88+
} catch (e) {
89+
void this.logger.log(
90+
`Failed to close file handle: ${getErrorMessage(e)}`,
91+
);
92+
}
8093
this.fileHandle = undefined;
8194
}
8295
}

0 commit comments

Comments
 (0)