Closed pawel-id closed 2 weeks 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.
Here are last few lines of a log. It might be helpful to determine failing operation
{"level":20,"time":1714094822092,"name":"sf:elapsedTime","msg":"CodeCoverage.queryAggregateCodeCov - exit","elapsedTime":1587.355986}
{"level":20,"time":1714094822094,"name":"sf:elapsedTime","msg":"CodeCoverage.getAggregateCodeCoverage - exit","elapsedTime":1590.129882}
{"level":20,"time":1714094822094,"name":"sf:elapsedTime","msg":"CodeCoverage.getOrgWideCoverage - enter"}
{"level":20,"time":1714094822095,"name":"sf:connection","method":"GET","url":"https://napoleon-broth-211.scratch.my.salesforce.com/services/data/v60.0/tooling/query?q=SELECT%20PercentCovered%20FROM%20ApexOrgWideCoverage","headers":{"content-type":"application/json","user-agent":"sfdx toolbelt:"},"msg":"request"}
{"level":20,"time":1714094822260,"name":"sf:elapsedTime","msg":"CodeCoverage.getOrgWideCoverage - exit","elapsedTime":165.877896}
{"level":20,"time":1714094822260,"name":"sf:elapsedTime","msg":"AsyncTests.formatAsyncResults - exit","elapsedTime":1843305.83755}
{"level":20,"time":1714094822260,"name":"sf:elapsedTime","msg":"AsyncTests.runTests - exit","elapsedTime":22977229.298226}
{"level":20,"time":1714094822260,"name":"sf:elapsedTime","msg":"TestService.runTestAsynchronous - exit","elapsedTime":22977229.389393}
{"level":20,"time":1714094822415,"name":"sf:elapsedTime","msg":"JUnitReporter.format - enter"}
{"level":20,"time":1714094822415,"name":"sf:elapsedTime","msg":"JUnitReporter.buildProperties - enter"}
{"level":20,"time":1714094822417,"name":"sf:elapsedTime","msg":"JUnitReporter.buildProperties - exit","elapsedTime":1.823485}
{"level":20,"time":1714094822417,"name":"sf:elapsedTime","msg":"JUnitReporter.buildTestCases - enter"}
{"level":20,"time":1714094822475,"name":"sf:elapsedTime","msg":"JUnitReporter.buildTestCases - exit","elapsedTime":57.704141}
{"level":20,"time":1714094822475,"name":"sf:elapsedTime","msg":"JUnitReporter.format - exit","elapsedTime":59.935349}
{"level":20,"time":1714094822476,"name":"sf:elapsedTime","msg":"TestService.writeResultFiles - enter"}
Starting with version @salesforce/cli/2.37.4
Could you try installing plugin-apex 3.1.3 (the version used by sf@2.36.8) and see if that resolves the issue? sf plugins install apex@3.1.3
I'm asking because that was the last version before we updated the underlying apex-node library to a new major version. If 3.1.3 works for you then we know that this issue is likely coming from that new major version
Thanks!
Could you try installing plugin-apex 3.1.3 (the version used by sf@2.36.8) and see if that resolves the issue?
sf plugins install apex@3.1.3
yes, it resolves the issue.
One more observation. I was casually looking at memory consumption of node process while running the command with apex 3.1.3. It seems it is doing some querying of an org for half an hour (code coverage?). During this time memory consumption steadily rose to 400MB. Then rapidly consume 1.7GB and then quit. As I wrote it doesn’t fail, but the memory consumption still seems much too high.
On apex 3.1.11 the memory consumption exceeds 4GB and it fails.
The numbers above are for our project. You are welcome to use scratch orgs provided for debugging the issue.
This issue has been linked to a new work item: W-15724695
@pawel-id Maybe you want to switch to use only Aggregated Code Coverage. That solved the memory issues for us: https://github.com/forcedotcom/salesforcedx-vscode/issues/5554#issuecomment-2096849948
Issue has been fixed and the code change is released in v61.1.2 of the Salesforce Extensions for VSCode ✅
Summary
We have quite big project having currently c.a. 2300+ apex tests. Starting with version @salesforce/cli/2.37.4 we are experiencing heap out memory when triggering those tests via CLI. The tests on the org runs fine, however on the CLI we have:
It seems that CLI tries to allocate more then 4GB memory and fails.
Affected commands:
sf apex run test -c -v -r junit -w 480 -l RunLocalTests -d output
- this is complete command we initially found that problem. It runs the tests for many hours and then do some post-processing and finally fail.sf apex get test -c -i 707afas... -d output
- this is a bit simpler command retrieving existing test run and doing only the post processing. It fails the same way, but it doesn’t require to run tests, but rather gather existing tests and doing some post processing. This is minimal and convenient way to replicate.Steps to reproduce
707...
sf apex get test -c -i 7073O00002aQRQqQAO -c -d output
. This usually takes 15-20 min and then it fails with heap out of memory.NODE_OPTIONS=--max-old-space-size=4096
(just guessing).Expected result
Test report saved into
output
folder.Actual result
The CLI exists with non zero exit code and heap out of memory as above.
System Information
We replicated this on macOS, Linux and Windows. It seems not OS dependent.