summaryrefslogtreecommitdiff
path: root/extension/src/activation
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-08-05 00:07:11 -0700
committerNate Sesti <sestinj@gmail.com>2023-08-05 00:07:11 -0700
commit68233071dd0d97a353a66fe5627d69f97a389ca8 (patch)
tree2e1904c10a7db0a21abc9f37cd28bad2a1934e7c /extension/src/activation
parent9620ba0154bde0778a0fe453d9dab29ae9a8082d (diff)
downloadsncontinue-68233071dd0d97a353a66fe5627d69f97a389ca8.tar.gz
sncontinue-68233071dd0d97a353a66fe5627d69f97a389ca8.tar.bz2
sncontinue-68233071dd0d97a353a66fe5627d69f97a389ca8.zip
fix: :bug: set api_keys in config.py, fix spawn error handling
Diffstat (limited to 'extension/src/activation')
-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();