forcedotcom / salesforcedx-apex

Salesforce Apex Node Library
BSD 3-Clause "New" or "Revised" License
19 stars 25 forks source link

force:apex:test:run can throw "CLIError: timed out" beginning in v1.6 (CLI v7.185) #316

Closed klewis-sfdc closed 1 year ago

klewis-sfdc commented 1 year ago

Summary

Users have reported seeing a CLIError: timed out error when running sfdx force:apex:test:run --resultformat junit --testlevel RunSpecifiedTests --wait=-1 for test suites that were running fine in previous versions starting in cli release 7.185.

The error message also states: ERROR running force:apex:test:run: Unknown error in Apex Library: timed out.

7.185 is the first CLI version to be released with apex-node library 1.6 (via plugin-source 2.3.15).

Steps To Reproduce:

TBD

Expected result

A test suite that runs successfully under CLI version 7.184 should also run successfully under CLI version 7.185.

Actual result

The test suite fails under version 7.185, and the output is not formatted as valid XML.

Additional information

Apex library Version: 1.6

OS and version:

bdovh commented 1 year ago

Affects me

bdovh commented 1 year ago

I am executing a SFDX CLI command to run apex tests

sfdx force:apex:test:run -l RunLocalTests --loglevel=trace -y -c -r json -d ./tests/apex -w 20

but it fails with a Timeout error. Even when I tried to increase the -wait parameter like this

sfdx force:apex:test:run -l RunLocalTests --loglevel=trace -y -c -r json -d ./tests/apex -w 999999

it still fails with the same error:

echo $(sfdx force:apex:test:run -l RunLocalTests --loglevel=trace -y -c -r json -d ./tests/apex -w 999999) > tests.json WARNING: WARNING: In the Summer ’21 release, we'll rename or remove some of the output files that are created when you run force:apex:test:run or force:apex:test:report with the --outputdir (-d) parameter. This breaking change could impact your CI/CD scripts if they reference specific filenames. See https://sfdc.co/apex-test-updates for details

CLIError: timed out at Object.error (/usr/local/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/errors/index.js:28:15) at /usr/local/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/cli-ux/index.js:25:66 at async flush (/usr/local/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/cli-ux/index.js:124:9) { oclif: { exit: 2 }, code: undefined } ERROR running force:apex:test:run: Unknown error in Apex Library: timed out

waltonzt commented 1 year ago

This affects me as well. It just started happening in our CI.

CLIError: timed out
    at Object.error (/opt/hostedtoolcache/node/18.13.0/x64/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/errors/index.js:28:15)
    at /opt/hostedtoolcache/node/18.13.0/x64/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/cli-ux/index.js:25:66
    at async flush (/opt/hostedtoolcache/node/18.13.0/x64/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/cli-ux/index.js:124:9) {
  oclif: { exit: 2 },
  code: undefined
}
bdovh commented 1 year ago

trying to replace npm install -g sfdx-cli by npm install -g sfdx-cli@7.184.0 in the CI script file to downgrade the SFDX CLI version and avoid the error

waltonzt commented 1 year ago

@bdovh Yeah that is what I am having to do until this is resolved. Thanks for suggestion though!

klewis-sfdc commented 1 year ago

Closing this as fixed via an update to the sfdx cli. The update should be included in the cli latest release candidate, which is 7.186.2.