forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
947 stars 405 forks source link

SFDX is not properly ignoring non-salesforce workspaces #5463

Closed paustint closed 6 months ago

paustint commented 6 months ago

Summary

I have a workspace which has nothing related to salesforce, but when I start vscode (or restart extension host), this extension incorrectly activates and creates 3K+ files in an .sfdx folder (which is not in my .gitignore because this is not an SFDX project).

In that past, I would often see an error pop up "This is not an sfdx workspace" or something like that, which was really annoying and I had considered filing a bug for that but never got around to it.

The issue does not happen every time and not sure exactly how to reproduce it.

Steps To Reproduce:

  1. open vscode in a non-sfdx workspace
  2. restart extension host (maybe a few times)

Expected result

if sfdx extensions are installed and I am in a non-sfdx workspace, the extension should remain 100% dormant. files should never be created, I should never see any notifications etc..

Actual result

sfdx invades all workspaces and creates .sfdx folder with thousands of files. and sometimes shows error notifications about missing project file.

Additional information

image

image

Salesforce Extension Version in VS Code: v60.1.2 (this does appear to have updated recently)

SFDX CLI Version: 2.22.7

OS and version: osx latest

VS Code version: 1.86.2

peternhale commented 6 months ago

@paustint I was unable to reproduce this in my environment. Could you check to see if any of the parent directories of you project has an sfdx-project.json file?

paustint commented 6 months ago

I'll try to determine that when back at my computer. It only happened once and does not appear to continue to happen - so not exactly sure what happened. I will play around with restarting vscode and restarting extension host etc...

peternhale commented 6 months ago

@paustint thank you. I am going to close this issue. Please feel free to reopen it if you encounter the problem again.

paustint commented 6 months ago

@peternhale - Is it normal that the extension shows an error message for all non-sfdx projects? This is really annoying to see this every time I start VSCode in non-sfdx workspaces.

These are the only things that show up in the output logs (this is from extension host output)

2024-02-27 07:22:08.596 [info] ExtensionService#_doActivateExtension salesforce.salesforce-vscode-slds, startup: false, activationEvent: 'onLanguage:javascript'
2024-02-27 07:22:08.638 [info] ExtensionService#_doActivateExtension salesforce.salesforcedx-vscode-core, startup: false, activationEvent: 'onView:sfdx.tasks.view'

image

image

image

peternhale commented 6 months ago

@paustint extensions should not activate if preconditions for activation are not met.

vscode-core precondition is "workspaceContains:sfdx-project.json" so not sure what is happening. I tried this on a new folder whose contents are from a simple npm init and I am not seeing vscode-core mentioned in in ext host log.

I will see if I can find a reasonable explanation.

paustint commented 6 months ago

Here is the repo that I normally work in, but have seen the same happen on other computers with different codebases. there is not an sfdx-project.json in the codebase, I am not using a multi-root workspace, and I have 100% confirmed that there is not an sfdx-project.json in any parent folders.

It is a very minor annoyance, so not something I am very concerned about.

peternhale commented 6 months ago

@paustint I just tried the jetstream project on my Mac with Salesforce Extension Pack v60.1.2 and I am not seeing either extension mentioned in the exthost log. I also tried with the expanded extension pack, with the same result.

Version: 1.86.2
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:42:13.651Z (2 wks ago)
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin x64 23.3.0
paustint commented 6 months ago

@peternhale - I don't know if this helps at all, but I just noticed that this entry is showing up in the "Extension Hosts" log when I start VSCode: 2024-03-10 08:53:04.306 [info] ExtensionService#_doActivateExtension salesforce.salesforcedx-vscode-core, startup: false, activationEvent: 'onView:sfdx.tasks.view'

paustint commented 6 months ago

@peternhale - lol, one other thing is that an .sfdx folder is magically created at the same time this error message shows up. I just downloaded a metadata package, unzipped, and opened in VSCode and I get the error (in my downloads folder) and then the sfdx folder is created.

This issue happens on 4 different computers, but I do have settings-sync so there must be something there.

These are the only user settings that seem related to this extension AFAIK

"salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home",
"settingsSync.ignoredSettings": ["salesforcedx-vscode-apex.java.home"],
image
skostojohn commented 5 months ago

I am seeing this same behavior, running extension pack 60.8.0

peternhale commented 5 months ago

@paustint @skostojohn what is the state of E4D extension for each of you.

skostojohn commented 5 months ago

@peternhale I think my issue was related to the einstein for developers extension. Once I removed that, I stopped having this problem.

paustint commented 5 months ago

I do not have einstein for developers installed, I just learned about it from your comments.

paustint commented 5 months ago

Also - I no longer see the .sfdx folder get created, but I still get the activation error message.

Video showing my experience https://jam.dev/c/420a2b18-d1ef-426d-81a0-6dff88a335c8