Skip to content

Commit d7b46e0

Browse files
author
Veetaha
committed
vscode-postrefactor: enforcing more reentrancy
1 parent 7f02d46 commit d7b46e0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

editors/code/src/installation/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function askToDownloadProperExtensionVersion(config: Config, reason = "")
9797
*
9898
* ACHTUNG!: this function has a crazy amount of state transitions, handling errors during
9999
* each of them would result in a ton of code (especially accounting for cross-process
100-
* shared mutable `globalState` access). Enforcing reentrancy for this is best-effort.
100+
* shared mutable `globalState` access). Enforcing no reentrancy for this is best-effort.
101101
*/
102102
const tryDownloadNightlyExtension = notReentrant(async function tryDownloadNightlyExtension(
103103
config: Config,

editors/code/src/installation/server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { spawnSync } from "child_process";
55
import { ArtifactSource } from "./interfaces";
66
import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info";
77
import { downloadArtifactWithProgressUi } from "./downloads";
8-
import { log, assert } from "../util";
8+
import { log, assert, notReentrant } from "../util";
99
import { Config, NIGHTLY_TAG } from "../config";
1010

1111
export async function ensureServerBinary(config: Config): Promise<null | string> {
@@ -82,7 +82,10 @@ function shouldDownloadServer(
8282
return installed.date.getTime() !== required.date.getTime();
8383
}
8484

85-
async function downloadServer(
85+
/**
86+
* Enforcing no reentrancy for this is best-effort.
87+
*/
88+
const downloadServer = notReentrant(async function downloadServer(
8689
source: ArtifactSource.GithubRelease,
8790
config: Config,
8891
): Promise<null | string> {
@@ -112,7 +115,7 @@ async function downloadServer(
112115
);
113116

114117
return binaryPath;
115-
}
118+
});
116119

117120
function isBinaryAvailable(binaryPath: string): boolean {
118121
const res = spawnSync(binaryPath, ["--version"]);

0 commit comments

Comments
 (0)