issue with the last release: cmd "flash" each time SF query is done
Hi
I just updated Salesforce CLI, and since, each time my script execute a sf command, a "cmd" windows is "flashing" and prevents me from working (app lost focus because the cmd get the focus).
Salesforce CLI version: @salesforce/cli/2.38.6 win32-x64 node-v20.12.1
I tried to screenshot this issue. It prevents me to work if my powershell script is running.
1/ Can you fix it ?
2/ How can I go back to the previous release as a workarround?
Thanks.
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.
Hello @THLG-MGP :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:
- Make sure you've provided detailed steps to reproduce your issue.
- A repository that clearly demonstrates the bug is ideal.
- Make sure you've installed the latest version of Salesforce CLI. (docs)
- Better yet, try the
rcornightlyversions. (docs)
- Better yet, try the
- Try running the
doctorcommand to diagnose common issues. - Search GitHub for existing related issues.
Thank you!
-
see comment here for information that we'd need https://github.com/forcedotcom/cli/issues/2833#issuecomment-2066768200. Also, it'd be helpful to have some minimal powershell script that would repro this
-
docs for previous releases are here https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm#sfdx_setup_install_cli_olderversions
I'd be very interested in where solves your problem.
sf version --verbose --json { "architecture": "win32-x64", "cliVersion": "@salesforce/cli/2.38.6", "nodeVersion": "node-v20.12.1", "osVersion": "Windows_NT 10.0.19045", "rootPath": "C:\Users\xxxxxxx\AppData\Local\sf\client\2.38.6-1d0ec8e", "shell": "cmd.exe", "pluginVersions": [ "@oclif/plugin-autocomplete 3.0.15 (core)", "@oclif/plugin-commands 3.3.1 (core)", "@oclif/plugin-help 6.0.21 (core)", "@oclif/plugin-not-found 3.1.4 (core)", "@oclif/plugin-plugins 5.0.10 (core)", "@oclif/plugin-search 1.0.22 (core)", "@oclif/plugin-update 4.2.6 (core)", "@oclif/plugin-version 2.0.17 (core)", "@oclif/plugin-warn-if-update-available 3.0.15 (core)", "@oclif/plugin-which 3.1.7 (core)", "@salesforce/cli 2.38.6 (core)", "apex 3.1.5 (core)", "auth 3.6.1 (core)", "data 3.3.1 (core)", "deploy-retrieve 3.6.2 (core)", "info 3.2.1 (core)", "limits 3.3.3 (core)", "marketplace 1.2.1 (core)", "org 4.1.1 (core)", "packaging 2.4.0 (core)", "schema 3.3.3 (core)", "settings 2.2.1 (core)", "sobject 1.3.3 (core)", "source 3.3.1 (core)", "telemetry 3.3.2 (core)", "templates 56.2.2 (core)", "trust 3.6.3 (core)", "user 3.5.2 (core)", "aura-helper-sf 1.1.1 (user)" ] }
I will wrote a powershell sample script to reproduce the issue
In the main time, how can I downgrade ? I gues if I uninstall then reinstall, I will have the same version ?
Thanks. Have a nice weekend.
Powershell code to reproduce the issue (cmd prompt will flashed) Replace $salesforce_url by your own. Each time sf data query is call, a windows cmd prompt is flahed Many thanks for your help. Kind Regards.
$salesforce_url="https://xxxxxx.sandbox.my.salesforce.com"
function login($url) {
sf org login web --instance-url $url --set-default
}
function logout() {
sf org logout --all --no-prompt
}
function execute_query($query) {
$res = sf data query --query $query --json | ConvertFrom-Json
return $res.result.records
}
function query_accounts() {
$query = "SELECT id from account LIMIT 10 "
execute_query -query $query
}
function query_contacts($accountId) {
$query = "SELECT Id, name, phone, email FROM Contact where Account_ID__c ='$($accountId)' "
execute_query -query $query
}
function doProcess() {
Write-Output "connection to Salesforce org instance..."
login -url $salesforce_url
Write-Output "getting data..."
$accounts=query_accounts
foreach($account in $accounts){
$contacts=query_contacts -accountId $account.Id
foreach($contact in $contacts){
Write-Output "$($contact.Name)"
}
}
logout
}
doProcess
In the main time, how can I downgrade ?
the previous comment has a link to our docs telling you how to do that
This issue has been linked to a new work item: W-15576746
This is definitely related to a security change that node forced (see https://github.com/forcedotcom/cli/issues/2822 for details).
It somehow doesn't seem to affect all windows users. I'm still trying to replicate it and find out what situations it could be happening in. If you've got more information or a reliable repro, please pile on!
Hi Many thanks for the feedback. I'm able to reproduce with the powershelll script shared with you. The issue happened when I updated Salesforce CLI last week. Unfortunatelly, I have no more glue :( I will try to reproduce the issue from a official docker image. I will keep you in touch. Many thanks. Kind Regards.
Hi I don't know if it can help, but I don't have the issue with @salesforce/cli/2.37.4 Thanks.
@mshanemc I can repro on Windows 11 Pro using standard command window (not Power Shell)
I'm game to let you look over my shoulder if you need to troubleshoot via screenshare
Here's a pair of files that demonstrate the issue with spawning a detached shell process: test-spawn.js
const cp = require('child_process');
nodePath = process.argv[0]
cp.spawn(nodePath, ['./wait.js'], {
shell: true,
detached: true,
windowsHide: true,
stdio: 'ignore',
})
wait.js
async function main() {
for (let i = 1; i <= 5; i++) {
console.log("Sleep " + i);
await new Promise(resolve => setTimeout(resolve, 1000));
}
console.log("Done");
}
main()
On my machine, Node v20.11.0, Windows 10 Enterprise 22H2 19045.4170, running node.exe test-spawn.js in a command window then spawns wait.js in a second window - even with windowsHide set to true. This occurs when running from CMD, Powershell, or Git Bash.
Retested my example in v20.12.2, same behavior. Running spawn() with shell:true and detached:true opens a new window.
The original fix for #2822 was due to the Node fix for CVE-2024-27980. This CVE noted that calling Win32 CreateProcess() with a .BAT or .CMD file could result in a vulnerability in program arguments. The Node fix was to disallow calling spawn() on a BAT or CMD file unless shell:true was set. When shell:true is set, spawn() will actually run 'cmd.exe /d /s /c "[batchfile] [arguments]"', which will process the arguments correctly.
Issue #2822 needed to be fixed because the post-install script ran a command file "run.cmd". However, there was a further PR to plugin-telemetry ( https://github.com/salesforcecli/plugin-telemetry/pull/611 ) that added shell:true to a detached spawn() call. This call actually spawns "node.exe" (process.argv[0]), which is not a BAT or CMD file. The shell:true option should not be necessary.
I have the same issue, after updating sf last week cmd started flashing when I use cli.
I had node v16, updated to node v20.13.1(issues was on both versions), Windows 11 23H2.@salesforce/cli/2.41.8.
I started using 2.37.4-fb2a8ae where I do not have such issue..
This issue is fixed in the 2.42.6 (May 22, 2024) release.