forcedotcom / salesforcedx-vscode

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

Unable to use VSCode Apex Debugger. Suspect the issue is due to recent migration from SFDX to SF #4927

Closed supert3d closed 1 year ago

supert3d commented 1 year ago

Summary

Unable to use VSCode Apex Debugger (official Salesforce plugin). Suspect the issue is due to recent migration from SFDX to SF Warning: Deprecated environment variable: SFDX_DEFAULTUSERNAME. Please use SF_TARGET_ORG instead.

Steps To Reproduce

  1. Checked sf and sfdx versioning. Ensured latest.
  2. Ensured SF permission sets were assigned correctly (Debug Apex) - https://developer.salesforce.com/tools/vscode/en/apex/interactive-debugger
  3. Checked had configuration set in VSCode launch.json
  4. Set a breakpoint in code.
  5. F5 - Launch Apex Debugger
  6. Debugger errors.

Expected result

Debugger runs

Actual result

Debugger errors with VSCode/Windows error... An unexpected error occurred while launching the debugger session. Refer to the Debug Console for details.

Debug Console message...

Connected to Streaming API channel /systemTopic/ApexDebuggerSystemEvent.
Connected to Streaming API channel /systemTopic/ApexDebuggerEvent.
Command returned the following error:
(node:25160) Warning: Deprecated environment variable: SFDX_DEFAULTUSERNAME. Please use SF_TARGET_ORG instead.
(Use `node --trace-warnings` ... to show where the warning was created)
(node:25160) Warning: Deprecated environment variable: SFDX_INSTANCE_URL. Please use SF_ORG_INSTANCE_URL instead.

System Information

GitBash for windows.

$ git version`
git version 2.39.1.windows.1
$ sf version --verbose --json
{
  "cliVersion": "@salesforce/cli/1.83.0",
  "architecture": "win32-x64",
  "nodeVersion": "node-v18.15.0",
  "osVersion": "Windows_NT 10.0.22621",
  "shell": "cmd.exe",
  "rootPath": "C:\\Users\\tonyc\\AppData\\Local\\sfdx\\client\\7.205.6-dfc6717\\sf",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.0 (core)",
    "@oclif/plugin-commands 2.2.15 (core)",
    "@oclif/plugin-help 5.2.9 (core)",
    "@oclif/plugin-not-found 2.3.24 (core)",
    "@oclif/plugin-plugins 3.1.2 (core)",
    "@oclif/plugin-search 0.0.17 (core)",
    "@oclif/plugin-update 3.1.17 (core)",
    "@oclif/plugin-version 1.3.4 (core)",
    "@oclif/plugin-warn-if-update-available 2.0.37 (core)",
    "@oclif/plugin-which 2.2.22 (core)",
    "@salesforce/cli 1.83.0 (core)",
    "apex 2.3.3 (core)",
    "auth 2.8.1 (core)",
    "data 2.3.22 (core)",
    "deploy-retrieve 1.11.7 (core)",
    "functions 1.21.10 (user)",
    "info 2.6.19 (core)",
    "limits 2.3.18 (core)",
    "login 1.2.11 (core)",
    "org 2.9.8 (core)",
    "schema 2.3.12 (core)",
    "settings 1.4.11 (core)",
    "sobject 0.1.24 (core)",
    "source 2.10.14 (core)",
    "telemetry 2.2.0 (core)",
    "templates 55.4.20 (core)",
    "trust 2.4.20 (core)",
    "user 2.3.17 (core)"
  ]
}

Additional information

I have also run these commands here to try and set the SFDX_DEFAULTUSERNAME and SFDX_INSTANCE_URL environment variables and it doesn't make a difference.

https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm

github-actions[bot] commented 1 year ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

github-actions[bot] commented 1 year ago

Hello @supert3d :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

supert3d commented 1 year ago
$ sf version --verbose --json
{
  "cliVersion": "@salesforce/cli/1.83.0",
  "architecture": "win32-x64",
  "nodeVersion": "node-v18.15.0",
  "osVersion": "Windows_NT 10.0.22621",
  "shell": "cmd.exe",
  "rootPath": "C:\\Users\\tonyc\\AppData\\Local\\sfdx\\client\\7.205.6-dfc6717\\sf",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.0 (core)",
    "@oclif/plugin-commands 2.2.15 (core)",
    "@oclif/plugin-help 5.2.9 (core)",
    "@oclif/plugin-not-found 2.3.24 (core)",
    "@oclif/plugin-plugins 3.1.2 (core)",
    "@oclif/plugin-search 0.0.17 (core)",
    "@oclif/plugin-update 3.1.17 (core)",
    "@oclif/plugin-version 1.3.4 (core)",
    "@oclif/plugin-warn-if-update-available 2.0.37 (core)",
    "@oclif/plugin-which 2.2.22 (core)",
    "@salesforce/cli 1.83.0 (core)",
    "apex 2.3.3 (core)",
    "auth 2.8.1 (core)",
    "data 2.3.22 (core)",
    "deploy-retrieve 1.11.7 (core)",
    "functions 1.21.10 (user)",
    "info 2.6.19 (core)",
    "limits 2.3.18 (core)",
    "login 1.2.11 (core)",
    "org 2.9.8 (core)",
    "schema 2.3.12 (core)",
    "settings 1.4.11 (core)",
    "sobject 0.1.24 (core)",
    "source 2.10.14 (core)",
    "telemetry 2.2.0 (core)",
    "templates 55.4.20 (core)",
    "trust 2.4.20 (core)",
    "user 2.3.17 (core)"
  ]
}
mshanemc commented 1 year ago

Those aren't errors, just warnings. the CLI recognizes the both the old and new Env names.

I'll transfer this to the vscode extension repo.

supert3d commented 1 year ago

Cheers there @mshanemc - I think, for whatever reason, those warnings in the console stop the VSCode debugger stream. Cheers again!

pogilvieCB commented 1 year ago

I'll confirm the vscode extension seems to be treating these warnings as errors.

Connected to Streaming API channel /systemTopic/ApexDebuggerSystemEvent.
Connected to Streaming API channel /systemTopic/ApexDebuggerEvent.
Command returned the following error:
(node:35301) Warning: Deprecated environment variable: SFDX_INSTANCE_URL. Please use SF_ORG_INSTANCE_URL instead.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:35301) Warning: Deprecated environment variable: SFDX_DEFAULTUSERNAME. Please use SF_TARGET_ORG instead.

The apex reply debugger is not working.

pogilvieCB commented 1 year ago

I filed case: Case #44888728 Apex replay debugger not compatible with updates to sfdx

supert3d commented 1 year ago

@pogilvieCB - Cheers for confirming mate. Could you hyperlink the case you have open for the Apex Replay Debugger? Would 100% agree it's seems to have been with all the recent updates and push to get people to migrate from sfdx to sf

RitamAgrawal commented 1 year ago

I'm not able to reproduce this issue. @supert3d & @pogilvieCB Are you able to run SFDX: Launch Apex Replay Debugger with Current File command on an Anonymous apex file?

supert3d commented 1 year ago

@RitamAgrawal - Yes. Steps used to test:

  1. Create Anonymous Apex file ([file].apex)
  2. SFDX: Launch Apex Replay Debugger with Current File
  3. Debug Output successful and replay successful.

@pogilvieCB issue is with Apex Replay Debugger. My issue is with Apex Debugger (not replay).

Steps to recreate my issue:

  1. Configure launch.json file for "name": "Launch Apex Debugger",
  2. Set breakpoints in Apex Class file
  3. SFDX: Update Checkpoints in Org
  4. Run and Debug (Apex Debugger - from "command strip" in VSCode) (Ctrl+D) - Fails

Debug Output:


Connected to Streaming API channel /systemTopic/ApexDebuggerEvent.
Command returned the following error:
(node:1724) Warning: Deprecated environment variable: SFDX_DEFAULTUSERNAME. Please use SF_TARGET_ORG instead.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1724) Warning: Deprecated environment variable: SFDX_INSTANCE_URL. Please use SF_ORG_INSTANCE_URL instead.```

Then modal to launch `launch.json`
RitamAgrawal commented 1 year ago

@supert3d & @pogilvieCB Thank you for your clarification in response. I was able to repro it for Apex Debugger and will include this in our current roadmap. Correct me if I'm wrong here, my understanding is:

supert3d commented 1 year ago

Heya there @RitamAgrawal 💯 - Awesome and thank you! 🙏🏻

supert3d commented 1 year ago

Just popped back to say thanks all for getting this resolved! Working brilliantly now!