Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please remove your debugger; statements in production builds #4056

Closed
paulober opened this issue Sep 10, 2024 · 5 comments
Closed

Please remove your debugger; statements in production builds #4056

paulober opened this issue Sep 10, 2024 · 5 comments
Labels
more info needed More info is needed from the community for us to properly triage and investigate.

Comments

@paulober
Copy link
Contributor

paulober commented Sep 10, 2024

Brief Issue Summary

Currently the released main.js in the cmake-tools extension includes serveral debugger; statements like in line 11006, 110061, 97194, 97223, 97311 and some more.
Since CMake-tools already floods the dev console, these debugger statements only add to the frustration, making it even more difficult to debug your own extensions when the extension is installed and enabled. Especially when working with virtual workspaces, it's all too common to get stuck in your own source code.

CMake Tools Diagnostics

<ERROR>

Debug Log

<ERROR>

Additional Information

An excerpt from the dev console:

console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.694Z [info] [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --version (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.825Z [info] [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E capabilities (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.955Z [debug] [main] Safe constructing new CMakeProject instance (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.956Z [debug] [variant] Constructing VariantManager (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.957Z [debug] [main] Constructing new CMakeProject instance (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.958Z [debug] [main] Starting CMake Tools second-phase init (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.959Z [debug] [expand] expanded ${workspaceFolder} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:08.982Z [debug] [kit] Reading kits file C:\Users\MyUser\AppData\Local\CMakeTools\cmake-tools-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.057Z [info] [kit] Successfully loaded 0 kits from C:\Users\MyUser\AppData\Local\CMakeTools\cmake-tools-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.209Z [debug] [kit] Not reading non-existent kits file: c:\Users\MyUser\PicoDevTest\sdgsdfg\.vscode\cmake-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.238Z [info] [variant] Loaded new set of variants (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.239Z [debug] [main] CMakeProject instance initialization complete. (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.240Z [debug] [main] Safe constructing new CMakeProject instance (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.241Z [debug] [variant] Constructing VariantManager (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.242Z [debug] [main] Constructing new CMakeProject instance (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.243Z [debug] [main] Starting CMake Tools second-phase init (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.245Z [warning] [expand] Invalid variable reference ${workspaceFolder} in string: ${workspaceFolder} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
C @ console.ts:137
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.246Z [debug] [expand] expanded ${workspaceFolder} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
log.ts:439   ERR [Extension Host] [CMakeTools] 2024-09-10T16:46:09.251Z [error] [rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"${workspaceFolder}"}
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:09.251Z [error] [rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"${workspaceFolder}"} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
C @ console.ts:137
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:24.820Z [debug] [main] Not starting CMake driver: no kit selected (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:24.834Z [debug] [kit] Reading kits file C:\Users\MyUser\AppData\Local\CMakeTools\cmake-tools-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:24.864Z [info] [kit] Successfully loaded 0 kits from C:\Users\MyUser\AppData\Local\CMakeTools\cmake-tools-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:25.121Z [debug] [kit] Not reading non-existent kits file: \.vscode\cmake-kits.json (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:25.122Z [debug] [expand] expanded ${workspaceFolder} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
log.ts:439   ERR [Extension Host] [CMakeTools] 2024-09-10T16:46:25.123Z [error] [rollbar] "sourceDirectory" is not a directory {"sourceDirectory":""}
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:25.123Z [error] [rollbar] "sourceDirectory" is not a directory {"sourceDirectory":""} (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
C @ console.ts:137
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:26.317Z [info] [variant] Loaded new set of variants (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:26.318Z [debug] [main] CMakeProject instance initialization complete. (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
log.ts:439   ERR [Extension Host] [CMakeTools] 2024-09-10T16:46:26.373Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: Post-folder-open false [object Object]
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:26.373Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: Post-folder-open false [object Object] (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
C @ console.ts:137
console.ts:137 [Extension Host] [CMakeTools] 2024-09-10T16:46:32.313Z [debug] [main] Not starting CMake driver: no kit selected (at console.<anonymous> (c:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:151:47754))
@github-project-automation github-project-automation bot moved this to Blocked in CMake Tools Sep 10, 2024
@paulober paulober changed the title Please remove your debugger statements in production builds Please remove your debugger; statements in production builds Sep 10, 2024
@gcampbell-msft
Copy link
Collaborator

@paulober You can control how much logging comes from our extension by setting the cmake.loggingLevel to info and maybe of these will not be sent.

@github-project-automation github-project-automation bot moved this from Blocked to Completed in CMake Tools Sep 10, 2024
@Yingzi1234 Yingzi1234 added more info needed More info is needed from the community for us to properly triage and investigate. and removed triage labels Sep 12, 2024
@gcampbell-msft gcampbell-msft closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2024
paulober added a commit to paulober/vscode-cmake-tools that referenced this issue Sep 18, 2024
Signed-off-by: paulober <44974737+paulober@users.noreply.github.com>
@paulober
Copy link
Contributor Author

@gcampbell-msft Please reopen and remove the debugger calls. It's just rude for other extension devs.
I also did do your work and created a very simple PR which integrates with your current webpack build system to not execute debugger statements in production.
As you already use production and development mode for your webpack setup it auto-detects this and guards the statements.

(Sorry for my tone but deploying debugger statements and then shutting of people reporting it (twice) triggers me. Therefor I created a quick PR that will fix this in the next release)

@paulober
Copy link
Contributor Author

paulober commented Sep 18, 2024

And @Yingzi1234, as per your request for more information on whether debugger statements should be included in production code, I conduced a little research and here's a brief excerpt from LinkedIn's Web Developer advice:

To use a debugger statement effectively, you need to follow some best practices and tips. For instance, you should only use a debugger statement for temporary debugging purposes and never leave it in production code.

[...]

Finally, it is wise to add comments or console.log statements to mark the places where you have inserted debugger statements. This will help you remember to remove them later and avoid confusion with other parts of your code.

source: https://www.linkedin.com/advice/1/what-debugger-statement-how-can-you-use-effectively

Or in one of the expert comments on this article:

  • Use it temporarily for debugging and remove it from production code.

or

Solely utilize debugger statements for temporary debugging needs.
Avoid leaving debugger statements in production code.

or

It is advisable to remove or disable debugger statements in production code to avoid any unnecessary overhead.

and a last one from a different source:

By definition such statement must absolutely be removed from the source code to prevent any unexpected behavior or added vulnerability to attacks in production.

@gcampbell-msft
Copy link
Collaborator

@paulober Thanks for the PR! We greatly appreciate it, I'll review it now 👍

@paulober
Copy link
Contributor Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed More info is needed from the community for us to properly triage and investigate.
Projects
Status: Completed
Development

No branches or pull requests

3 participants