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

issue with the last release: cmd "flash" each time SF query is done #2833

Closed
THLG-MGP opened this issue Apr 19, 2024 · 15 comments
Closed

issue with the last release: cmd "flash" each time SF query is done #2833

THLG-MGP opened this issue Apr 19, 2024 · 15 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@THLG-MGP
Copy link

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?
Sans titre

Thanks.

@THLG-MGP THLG-MGP added the investigating We're actively investigating this issue label Apr 19, 2024
Copy link

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.

Copy link

Hello @THLG-MGP 👋 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 rc or nightly versions. (docs)
  • Try running the doctor command to diagnose common issues.
  • Search GitHub for existing related issues.

Thank you!

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Apr 19, 2024
@mshanemc
Copy link
Contributor

  1. see comment here for information that we'd need issue with the last release: cmd "flash" each time SF query is done #2833 (comment). Also, it'd be helpful to have some minimal powershell script that would repro this

  2. 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.

@THLG-MGP
Copy link
Author

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.

@github-actions github-actions bot added validated Version information for this issue has been validated investigating We're actively investigating this issue and removed more information required Issue requires more information or a response from the customer labels Apr 19, 2024
@THLG-MGP
Copy link
Author

THLG-MGP commented Apr 19, 2024

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

@mshanemc
Copy link
Contributor

mshanemc commented Apr 19, 2024

In the main time, how can I downgrade ?

the previous comment has a link to our docs telling you how to do that

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Apr 22, 2024
Copy link

git2gus bot commented Apr 22, 2024

This issue has been linked to a new work item: W-15576746

@mshanemc
Copy link
Contributor

This is definitely related to a security change that node forced (see #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!

@THLG-MGP
Copy link
Author

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.

@THLG-MGP
Copy link
Author

Hi
I don't know if it can help, but I don't have the issue with @salesforce/cli/2.37.4
Thanks.

@daveespo
Copy link

@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

@jaklein
Copy link

jaklein commented May 3, 2024

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.

@jaklein
Copy link

jaklein commented May 3, 2024

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 ( salesforcecli/plugin-telemetry#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.

@ih0ry
Copy link

ih0ry commented May 18, 2024

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.

image

I started using 2.37.4-fb2a8ae where I do not have such issue..

@jshackell-sfdc
Copy link
Collaborator

This issue is fixed in the 2.42.6 (May 22, 2024) release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

6 participants