summaryrefslogtreecommitdiff
path: root/extension/src
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src')
-rw-r--r--extension/src/activation/activate.ts3
-rw-r--r--extension/src/activation/environmentSetup.ts40
2 files changed, 24 insertions, 19 deletions
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts
index 560b970c..831d1160 100644
--- a/extension/src/activation/activate.ts
+++ b/extension/src/activation/activate.ts
@@ -54,9 +54,8 @@ export async function activateExtension(context: vscode.ExtensionContext) {
registerAllCommands(context);
registerQuickFixProvider();
- // Start the server and display loader if taking > 2 seconds
+ // Start the server
const sessionIdPromise = (async () => {
- // Start the server and set serverStarted to true when done
await startContinuePythonServer();
console.log("Continue server started");
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index d41cb289..1ca32841 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -231,23 +231,29 @@ export async function startContinuePythonServer() {
let delay = 1000; // Delay between each attempt in milliseconds
const spawnChild = () => {
- const child = spawn(destination, {
- detached: true,
- stdio: "ignore",
- });
-
- child.on("error", (err: any) => {
- if (attempts < maxAttempts) {
- attempts++;
- console.log(
- `Error caught (likely EBUSY). Retrying attempt ${attempts}...`
- );
- setTimeout(spawnChild, delay);
- } else {
- console.error("Failed to start subprocess.", err);
- }
- });
- child.unref();
+ const retry = () => {
+ attempts++;
+ console.log(
+ `Error caught (likely EBUSY). Retrying attempt ${attempts}...`
+ );
+ setTimeout(spawnChild, delay);
+ };
+ try {
+ const child = spawn(destination, {
+ detached: true,
+ stdio: "ignore",
+ });
+ child.on("error", (err: any) => {
+ if (attempts < maxAttempts) {
+ retry();
+ } else {
+ console.error("Failed to start subprocess.", err);
+ }
+ });
+ child.unref();
+ } catch (e: any) {
+ retry();
+ }
};
spawnChild();