From 053bab9235b4fea5824db6f6e83c4724671ee4f9 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:02:27 -0800 Subject: [PATCH 1/7] remove console. in production code --- src/client/browser/extension.ts | 5 ++-- .../process/worker/workerRawProcessApis.ts | 3 ++- src/client/common/utils/resourceLifecycle.ts | 5 ++-- src/client/deprecatedProposedApi.ts | 4 ++-- src/client/repl/pythonServer.ts | 2 +- src/client/telemetry/index.ts | 4 ++-- .../testing/testController/common/utils.ts | 4 ++-- .../pytest/pytestExecutionAdapter.ts | 23 ++++++++----------- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/client/browser/extension.ts b/src/client/browser/extension.ts index 35854d141cad..3d672b7f29e2 100644 --- a/src/client/browser/extension.ts +++ b/src/client/browser/extension.ts @@ -12,6 +12,7 @@ import { EventName } from '../telemetry/constants'; import { createStatusItem } from './intellisenseStatus'; import { PylanceApi } from '../activation/node/pylanceApi'; import { buildApi, IBrowserExtensionApi } from './api'; +import { traceError, traceLog } from '../logging'; interface BrowserConfig { distUrl: string; // URL to Pylance's dist folder. @@ -139,7 +140,7 @@ async function runPylance( await client.start(); } catch (e) { - console.log(e); + traceLog(e); } } @@ -200,7 +201,7 @@ function sendTelemetryEventBrowser( break; } } catch (exception) { - console.error(`Failed to serialize ${prop} for ${eventName}`, exception); + traceError(`Failed to serialize ${prop} for ${eventName}`, exception); } }); } diff --git a/src/client/common/process/worker/workerRawProcessApis.ts b/src/client/common/process/worker/workerRawProcessApis.ts index 5b04aaa40b0a..cfae9b1e6471 100644 --- a/src/client/common/process/worker/workerRawProcessApis.ts +++ b/src/client/common/process/worker/workerRawProcessApis.ts @@ -17,6 +17,7 @@ import { StdErrError, ExecutionResult, } from './types'; +import { traceWarn } from '../../../logging'; const PS_ERROR_SCREEN_BOGUS = /your [0-9]+x[0-9]+ screen size is bogus\. expect trouble/; @@ -208,6 +209,6 @@ function killPid(pid: number): void { process.kill(pid); } } catch { - console.warn('Unable to kill process with pid', pid); + traceWarn('Unable to kill process with pid', pid); } } diff --git a/src/client/common/utils/resourceLifecycle.ts b/src/client/common/utils/resourceLifecycle.ts index f41efebc12cb..b5d1a9a1c83a 100644 --- a/src/client/common/utils/resourceLifecycle.ts +++ b/src/client/common/utils/resourceLifecycle.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. // eslint-disable-next-line max-classes-per-file +import { traceWarn } from '../../logging'; import { IDisposable } from '../types'; import { Iterable } from './iterable'; @@ -32,7 +33,7 @@ export function dispose(arg: T | Iterable | undefined) try { d.dispose(); } catch (e) { - console.warn(`dispose() failed for ${d}`, e); + traceWarn(`dispose() failed for ${d}`, e); } } } @@ -149,7 +150,7 @@ export class DisposableStore implements IDisposable { if (this._isDisposed) { if (!DisposableStore.DISABLE_DISPOSED_WARNING) { - console.warn( + traceWarn( new Error( 'Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!', ).stack, diff --git a/src/client/deprecatedProposedApi.ts b/src/client/deprecatedProposedApi.ts index e63670e4bf1b..d0003c895517 100644 --- a/src/client/deprecatedProposedApi.ts +++ b/src/client/deprecatedProposedApi.ts @@ -13,7 +13,7 @@ import { } from './deprecatedProposedApiTypes'; import { IInterpreterService } from './interpreter/contracts'; import { IServiceContainer } from './ioc/types'; -import { traceVerbose } from './logging'; +import { traceVerbose, traceWarn } from './logging'; import { PythonEnvInfo } from './pythonEnvironments/base/info'; import { getEnvPath } from './pythonEnvironments/base/info/env'; import { GetRefreshEnvironmentsOptions, IDiscoveryAPI } from './pythonEnvironments/base/locator'; @@ -74,7 +74,7 @@ export function buildDeprecatedProposedApi( }); traceVerbose(`Extension ${info.extensionId} accessed ${apiName}`); if (warnLog && !warningLogged.has(info.extensionId)) { - console.warn( + traceWarn( `${info.extensionId} extension is using deprecated python APIs which will be removed soon.`, ); warningLogged.add(info.extensionId); diff --git a/src/client/repl/pythonServer.ts b/src/client/repl/pythonServer.ts index 0f500f0431bc..570433714f98 100644 --- a/src/client/repl/pythonServer.ts +++ b/src/client/repl/pythonServer.ts @@ -38,7 +38,7 @@ class PythonServerImpl implements PythonServer, Disposable { private initialize(): void { this.disposables.push( this.connection.onNotification('log', (message: string) => { - console.log('Log:', message); + traceLog('Log:', message); }), ); this.connection.listen(); diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 357f6e60768a..365a4e593f28 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -136,7 +136,7 @@ export function sendTelemetryEvent

{ - console.log(`Test Result named pipe ${pipeName} cancelled`); + traceLog(`Test Result named pipe ${pipeName} cancelled`); disposable.dispose(); }), ); @@ -345,7 +345,7 @@ export async function hasSymlinkParent(currentPath: string): Promise { // Recurse up the directory tree return await hasSymlinkParent(parentDirectory); } catch (error) { - console.error('Error checking symlinks:', error); + traceError('Error checking symlinks:', error); return false; } } diff --git a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts index 6413baf8baee..0a0d802ef32e 100644 --- a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts +++ b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts @@ -273,20 +273,17 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter { // if the child has testIds then this is a run request // if the child process exited with a non-zero exit code, then we need to send the error payload. if (code !== 0) { - traceError( - `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, - ); + traceError( + `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, + ); - if (runInstance) { - this.resultResolver?.resolveExecution( - utils.createExecutionErrorPayload(code, signal, testIds, cwd), - runInstance, - ); - } - // this doesn't work, it instead directs us to the noop one which is defined first - // potentially this is due to the server already being close, if this is the case? - console.log('right before serverDispose'); - } + if (runInstance) { + this.resultResolver?.resolveExecution( + utils.createExecutionErrorPayload(code, signal, testIds, cwd), + runInstance, + ); + } + } // deferredTillEOT is resolved when all data sent on stdout and stderr is received, close event is only called when this occurs // due to the sync reading of the output. From a75c7d5643761375c2c3d42c8aaca44282a4d5ed Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:11:34 -0800 Subject: [PATCH 2/7] format --- .../pytest/pytestExecutionAdapter.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts index 0a0d802ef32e..b408280a576e 100644 --- a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts +++ b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts @@ -273,17 +273,17 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter { // if the child has testIds then this is a run request // if the child process exited with a non-zero exit code, then we need to send the error payload. if (code !== 0) { - traceError( - `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, - ); + traceError( + `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, + ); - if (runInstance) { - this.resultResolver?.resolveExecution( - utils.createExecutionErrorPayload(code, signal, testIds, cwd), - runInstance, - ); - } - } + if (runInstance) { + this.resultResolver?.resolveExecution( + utils.createExecutionErrorPayload(code, signal, testIds, cwd), + runInstance, + ); + } + } // deferredTillEOT is resolved when all data sent on stdout and stderr is received, close event is only called when this occurs // due to the sync reading of the output. From bfe110fb30824f8354b368ab524530dcd61f5074 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:22:55 -0800 Subject: [PATCH 3/7] use actions-ecosystem --- .github/workflows/pr-file-check.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index fcdf91b4f64b..1d0f83476b8f 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -41,6 +41,11 @@ jobs: skip-label: 'skip tests' failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)' + - name: 'Add issue-please labe on PR open' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: 'issue-please' + - name: 'Ensure PR has an associated issue' uses: actions/github-script@v7 with: From 3bd24a6f5e8c6742e04a8c7e26f0645bad68dbd3 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:31:07 -0800 Subject: [PATCH 4/7] remove error --- .github/workflows/pr-file-check.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 1d0f83476b8f..fcdf91b4f64b 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -41,11 +41,6 @@ jobs: skip-label: 'skip tests' failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)' - - name: 'Add issue-please labe on PR open' - uses: actions-ecosystem/action-add-labels@v1 - with: - labels: 'issue-please' - - name: 'Ensure PR has an associated issue' uses: actions/github-script@v7 with: From 2021b691f38f8917fa4c7e47bef3fc12213b2bf0 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 17 Dec 2024 09:45:48 -0800 Subject: [PATCH 5/7] remove for browser --- src/client/browser/extension.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/browser/extension.ts b/src/client/browser/extension.ts index 3d672b7f29e2..132618430551 100644 --- a/src/client/browser/extension.ts +++ b/src/client/browser/extension.ts @@ -12,7 +12,6 @@ import { EventName } from '../telemetry/constants'; import { createStatusItem } from './intellisenseStatus'; import { PylanceApi } from '../activation/node/pylanceApi'; import { buildApi, IBrowserExtensionApi } from './api'; -import { traceError, traceLog } from '../logging'; interface BrowserConfig { distUrl: string; // URL to Pylance's dist folder. @@ -140,7 +139,7 @@ async function runPylance( await client.start(); } catch (e) { - traceLog(e); + console.log(e); // necessary to use console.log for browser } } @@ -201,7 +200,7 @@ function sendTelemetryEventBrowser( break; } } catch (exception) { - traceError(`Failed to serialize ${prop} for ${eventName}`, exception); + console.error(`Failed to serialize ${prop} for ${eventName}`, exception); // necessary to use console.log for browser } }); } From fa3d4a6ffa52aa2eadded94d91d50ccce98a4661 Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Tue, 17 Dec 2024 12:52:14 -0800 Subject: [PATCH 6/7] Update src/client/telemetry/index.ts Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com> --- src/client/telemetry/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 365a4e593f28..2d75aed3cdcc 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -136,7 +136,7 @@ export function sendTelemetryEvent

Date: Tue, 17 Dec 2024 12:52:20 -0800 Subject: [PATCH 7/7] Update src/client/telemetry/index.ts Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com> --- src/client/telemetry/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 2d75aed3cdcc..ba7e60bd6763 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -160,7 +160,7 @@ export function sendTelemetryEvent