From a86933aec5243584def582150bbba1a926be9fda Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 2 Jul 2023 12:47:08 -0700 Subject: ssl certificate fix --- extension/src/activation/environmentSetup.ts | 32 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index d4c81d2e..7e550ea8 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -71,9 +71,11 @@ async function getPythonPipCommands() { } } + let pipCmd = pythonCmd.endsWith("3") ? "pip3" : "pip"; + const version = stdout.split(" ")[1]; const [major, minor] = version.split("."); - if (parseInt(major) !== 3 || parseInt(minor) < 7) { + if (parseInt(major) !== 3 || parseInt(minor) < 8) { // Need to check specific versions const checkPython3VersionExists = async (minorVersion: number) => { const [stdout, stderr] = await runCommand( @@ -82,24 +84,27 @@ async function getPythonPipCommands() { return typeof stderr === "undefined" || stderr === ""; }; - const validVersions = [7, 8, 9, 10, 11, 12]; + const VALID_VERSIONS = [8, 9, 10, 11, 12]; let versionExists = false; - for (const minorVersion of validVersions) { + for (const minorVersion of VALID_VERSIONS) { if (await checkPython3VersionExists(minorVersion)) { versionExists = true; - break; + pythonCmd = `python3.${minorVersion}`; + pipCmd = `pip3.${minorVersion}`; } } if (!versionExists) { vscode.window.showErrorMessage( - "Continue requires Python3 version 3.7 or greater. Please update your Python3 installation, reload VS Code, and try again." + "Continue requires Python3 version 3.8 or greater. Please update your Python3 installation, reload VS Code, and try again." ); - throw new Error("Python3 is not installed."); + throw new Error("Python3.8 or greater is not installed."); } + } else { + pythonCmd = `python${major}.${minor}`; + pipCmd = `pip${major}.${minor}`; } - const pipCmd = pythonCmd.endsWith("3") ? "pip3" : "pip"; return [pythonCmd, pipCmd]; } @@ -298,14 +303,13 @@ export async function startContinuePythonServer() { // Do this after above check so we don't have to waste time setting up the env await setupPythonEnv(); - let activateCmd = ". env/bin/activate"; - let pythonCmd = "python3"; - if (process.platform == "win32") { - activateCmd = ".\\env\\Scripts\\activate"; - pythonCmd = "python"; - } + const [pythonCmd] = await getPythonPipCommands(); + const activateCmd = + process.platform == "win32" + ? ".\\env\\Scripts\\activate" + : ". env/bin/activate"; - let command = `cd "${path.join( + const command = `cd "${path.join( getExtensionUri().fsPath, "scripts" )}" && ${activateCmd} && cd .. && ${pythonCmd} -m scripts.run_continue_server`; -- cgit v1.2.3-70-g09d2 From 5948aa251bde983fb3e5ee9782ce17879451f4b8 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 2 Jul 2023 15:22:34 -0700 Subject: telemetry to capture errors when setup fails --- continuedev/src/continuedev/libs/util/dedent.py | 2 + extension/package-lock.json | 149 +++++++++++++++++++++++- extension/package.json | 3 +- extension/src/activation/environmentSetup.ts | 67 ++++++----- 4 files changed, 187 insertions(+), 34 deletions(-) (limited to 'extension/src/activation') diff --git a/continuedev/src/continuedev/libs/util/dedent.py b/continuedev/src/continuedev/libs/util/dedent.py index 74edd173..bbbeba5e 100644 --- a/continuedev/src/continuedev/libs/util/dedent.py +++ b/continuedev/src/continuedev/libs/util/dedent.py @@ -3,6 +3,8 @@ from typing import Tuple def dedent_and_get_common_whitespace(s: str) -> Tuple[str, str]: lines = s.splitlines() + if len(lines) == 0: + return "", "" # Longest common whitespace prefix lcp = lines[0].split(lines[0].strip())[0] diff --git a/extension/package-lock.json b/extension/package-lock.json index 7e0c9cde..5ebd645c 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,17 +1,18 @@ { "name": "continue", - "version": "0.0.102", + "version": "0.0.103", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.102", + "version": "0.0.103", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", "@reduxjs/toolkit": "^1.9.3", "@segment/analytics-node": "^0.0.1-beta.16", + "@sentry/node": "^7.57.0", "@styled-icons/heroicons-outline": "^10.47.0", "@vitejs/plugin-react-swc": "^3.3.2", "axios": "^1.2.5", @@ -1331,6 +1332,71 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, + "node_modules/@sentry-internal/tracing": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.57.0.tgz", + "integrity": "sha512-tpViyDd8AhQGYYhI94xi2aaDopXOPfL2Apwrtb3qirWkomIQ2K86W1mPmkce+B0cFOnW2Dxv/ZTFKz6ghjK75A==", + "dependencies": { + "@sentry/core": "7.57.0", + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.57.0.tgz", + "integrity": "sha512-l014NudPH0vQlzybtXajPxYFfs9w762NoarjObC3gu76D1jzBBFzhdRelkGpDbSLNTIsKhEDDRpgAjBWJ9icfw==", + "dependencies": { + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.57.0.tgz", + "integrity": "sha512-63mjyUVM6sfJFVQ5TGVRVGUsoEfESl5ABzIW1W0s9gUiQPaG8SOdaQJglb2VNrkMYxnRHgD8Q9LUh/qcmUyPGw==", + "dependencies": { + "@sentry-internal/tracing": "7.57.0", + "@sentry/core": "7.57.0", + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "cookie": "^0.4.1", + "https-proxy-agent": "^5.0.0", + "lru_map": "^0.3.3", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/types": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.57.0.tgz", + "integrity": "sha512-D7ifoUfxuVCUyktIr5Gc+jXUbtcUMmfHdTtTbf1XCZHua5mJceK9wtl3YCg3eq/HK2Ppd52BKnTzEcS5ZKQM+w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.57.0.tgz", + "integrity": "sha512-YXrkMCiNklqkXctn4mKYkrzNCf/dfVcRUQrkXjeBC+PHXbcpPyaJgInNvztR7Skl8lE3JPGPN4v5XhLxK1bUUg==", + "dependencies": { + "@sentry/types": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -2940,6 +3006,14 @@ "node": "> 0.10" } }, + "node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -5183,6 +5257,11 @@ "node": ">=8" } }, + "node_modules/lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -8183,8 +8262,7 @@ "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -9808,6 +9886,56 @@ } } }, + "@sentry-internal/tracing": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.57.0.tgz", + "integrity": "sha512-tpViyDd8AhQGYYhI94xi2aaDopXOPfL2Apwrtb3qirWkomIQ2K86W1mPmkce+B0cFOnW2Dxv/ZTFKz6ghjK75A==", + "requires": { + "@sentry/core": "7.57.0", + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + } + }, + "@sentry/core": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.57.0.tgz", + "integrity": "sha512-l014NudPH0vQlzybtXajPxYFfs9w762NoarjObC3gu76D1jzBBFzhdRelkGpDbSLNTIsKhEDDRpgAjBWJ9icfw==", + "requires": { + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + } + }, + "@sentry/node": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.57.0.tgz", + "integrity": "sha512-63mjyUVM6sfJFVQ5TGVRVGUsoEfESl5ABzIW1W0s9gUiQPaG8SOdaQJglb2VNrkMYxnRHgD8Q9LUh/qcmUyPGw==", + "requires": { + "@sentry-internal/tracing": "7.57.0", + "@sentry/core": "7.57.0", + "@sentry/types": "7.57.0", + "@sentry/utils": "7.57.0", + "cookie": "^0.4.1", + "https-proxy-agent": "^5.0.0", + "lru_map": "^0.3.3", + "tslib": "^2.4.1 || ^1.9.3" + } + }, + "@sentry/types": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.57.0.tgz", + "integrity": "sha512-D7ifoUfxuVCUyktIr5Gc+jXUbtcUMmfHdTtTbf1XCZHua5mJceK9wtl3YCg3eq/HK2Ppd52BKnTzEcS5ZKQM+w==" + }, + "@sentry/utils": { + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.57.0.tgz", + "integrity": "sha512-YXrkMCiNklqkXctn4mKYkrzNCf/dfVcRUQrkXjeBC+PHXbcpPyaJgInNvztR7Skl8lE3JPGPN4v5XhLxK1bUUg==", + "requires": { + "@sentry/types": "7.57.0", + "tslib": "^2.4.1 || ^1.9.3" + } + }, "@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -10937,6 +11065,11 @@ "easy-table": "1.1.0" } }, + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + }, "core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -12603,6 +12736,11 @@ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" }, + "lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -14662,8 +14800,7 @@ "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "tsutils": { "version": "3.21.0", diff --git a/extension/package.json b/extension/package.json index 9d369724..b77ba064 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.102", + "version": "0.0.103", "publisher": "Continue", "engines": { "vscode": "^1.60.0" @@ -240,6 +240,7 @@ "@electron/rebuild": "^3.2.10", "@reduxjs/toolkit": "^1.9.3", "@segment/analytics-node": "^0.0.1-beta.16", + "@sentry/node": "^7.57.0", "@styled-icons/heroicons-outline": "^10.47.0", "@vitejs/plugin-react-swc": "^3.3.2", "axios": "^1.2.5", diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 7e550ea8..4e6be9b3 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -9,6 +9,7 @@ import { getContinueServerUrl } from "../bridge"; import fetch from "node-fetch"; import * as vscode from "vscode"; import fkill from "fkill"; +import { sendTelemetryEvent, TelemetryEvent } from "../telemetry"; const MAX_RETRIES = 5; async function retryThenFail( @@ -17,13 +18,16 @@ async function retryThenFail( ): Promise { try { return await fn(); - } catch (e) { + } catch (e: any) { if (retries > 0) { return await retryThenFail(fn, retries - 1); } vscode.window.showErrorMessage( "Failed to set up Continue extension. Please email nate@continue.dev and we'll get this fixed ASAP!" ); + sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { + error: e.message, + }); throw e; } } @@ -47,6 +51,12 @@ async function runCommand(cmd: string): Promise<[string, string | undefined]> { stdout = ""; } + if (stderr) { + sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { + error: stderr, + }); + } + return [stdout, stderr]; } @@ -288,33 +298,33 @@ export async function startContinuePythonServer() { return; } - if (await checkServerRunning(serverUrl)) { - // Kill the server if it is running an old version - if (fs.existsSync(serverVersionPath())) { - const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); - if (serverVersion === getExtensionVersion()) { - return; + return await retryThenFail(async () => { + if (await checkServerRunning(serverUrl)) { + // Kill the server if it is running an old version + if (fs.existsSync(serverVersionPath())) { + const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); + if (serverVersion === getExtensionVersion()) { + return; + } } + console.log("Killing old server..."); + await fkill(":65432"); } - console.log("Killing old server..."); - await fkill(":65432"); - } - // Do this after above check so we don't have to waste time setting up the env - await setupPythonEnv(); + // Do this after above check so we don't have to waste time setting up the env + await setupPythonEnv(); - const [pythonCmd] = await getPythonPipCommands(); - const activateCmd = - process.platform == "win32" - ? ".\\env\\Scripts\\activate" - : ". env/bin/activate"; + const [pythonCmd] = await getPythonPipCommands(); + const activateCmd = + process.platform == "win32" + ? ".\\env\\Scripts\\activate" + : ". env/bin/activate"; - const command = `cd "${path.join( - getExtensionUri().fsPath, - "scripts" - )}" && ${activateCmd} && cd .. && ${pythonCmd} -m scripts.run_continue_server`; + const command = `cd "${path.join( + getExtensionUri().fsPath, + "scripts" + )}" && ${activateCmd} && cd .. && ${pythonCmd} -m scripts.run_continue_server`; - return await retryThenFail(async () => { console.log("Starting Continue python server..."); return new Promise(async (resolve, reject) => { @@ -322,22 +332,25 @@ export async function startContinuePythonServer() { const child = spawn(command, { shell: true, }); - child.stdout.on("data", (data: any) => { - console.log(`stdout: ${data}`); - }); child.stderr.on("data", (data: any) => { + console.log(`stdout: ${data}`); if ( data.includes("Uvicorn running on") || // Successfully started the server data.includes("address already in use") // The server is already running (probably a simultaneously opened VS Code window) ) { console.log("Successfully started Continue python server"); resolve(null); - } else { - console.log(`stderr: ${data}`); + } else if (data.includes("ERROR") || data.includes("Traceback")) { + sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { + error: data, + }); } }); child.on("error", (error: any) => { console.log(`error: ${error.message}`); + sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { + error: error.message, + }); }); // Write the current version of vscode to a file called server_version.txt -- cgit v1.2.3-70-g09d2