-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Summary
Back in August we filed issue #3380 due to the sf apex run test command suddenly consuming over 10x as many API calls as it did previous to version 2.103.7. This was caused by the following change that implemented a 100 millisecond polling frequency:
A fix was put in place to reduce the polling frequency to 1 second (and was released as part of cli version 2.107.6):
https://github.com/forcedotcom/salesforcedx-apex/pull/569/files#diff-3d33659d87712dc71ec9f54c44bc17dd38d83e4fc2ecb3ea13774f5e06c189daR93
While this did reduce the API usage from what was seen in 2.103.7, as Dave pointed out in this comment, the API usage was still elevated from the behavior that existed back in 2.102.6.
Previous to https://github.com/forcedotcom/salesforcedx-apex/pull/507/files, it appears that asyncTests was using StreamingClient, which from what I can gather had a polling frequency of once per minute:
https://github.com/forcedotcom/salesforcedx-apex/blob/08576f0f227130ba87ee4d1f51b2cfc1043f4f1c/src/streaming/types.ts#L40
Therefore the CLI is still polling at a greatly increased frequency compared to historical. This becomes a problem for our CI jobs that run tests in developer orgs which only have a daily limit of 15,000 requests. One of our projects has over 2,000 tests, and given that the amount of time that test executions take in an org are highly variable (sometimes taking over 30 minutes), it's now very easy to exhaust an org's API limits after only a few test runs.
We're requesting that the polling frequency get reduced back to it's original state in 2.102.6, or even better would be a new flag that would allow the user to explicitly set the polling frequency to override the default value (different contexts might prefer different polling frequencies).
Steps To Reproduce
Run sf apex run test -w 60 -r human -d apex-test-results -y --concise on CLI versions 2.102.6, 2.103.7, and 2.107.6 and observe API usage.
Expected result
API usage should remain consistent.
Actual result
API usage is dramatically elevated.
System Information
{
"architecture": "win32-x64",
"cliVersion": "@salesforce/cli/2.112.6",
"nodeVersion": "node-v22.21.0",
"osVersion": "Windows_NT 10.0.26100",
"rootPath": "C:\\Users\\Jeffrey Azevedo\\AppData\\Local\\sf\\client\\2.112.6-a2963fb",
"shell": "powershell",
"pluginVersions": [
"@dx-cli-toolbox/sfdx-toolbox-package-utils 1.0.2 (user) published 216 days ago (Tue Apr 15 2025)",
"@oclif/plugin-autocomplete 3.2.39 (core)",
"@oclif/plugin-commands 4.1.37 (core)",
"@oclif/plugin-help 6.2.35 (core)",
"@oclif/plugin-not-found 3.2.72 (core)",
"@oclif/plugin-plugins 5.4.53 (core)",
"@oclif/plugin-search 1.2.35 (core)",
"@oclif/plugin-update 4.7.14 (core)",
"@oclif/plugin-version 2.2.36 (core)",
"@oclif/plugin-warn-if-update-available 3.1.52 (core)",
"@oclif/plugin-which 3.2.42 (core)",
"@salesforce/cli 2.112.6 (core)",
"agent 1.24.24 (core)",
"apex 3.8.6 (core)",
"api 1.3.3 (core)",
"auth 3.9.18 (core)",
"code-analyzer 5.6.1 (user) published 19 days ago (Wed Oct 29 2025)",
"data 4.0.60 (core)",
"deploy-retrieve 3.23.14 (core)",
"info 3.4.96 (core)",
"lightning-dev 4.5.2 (user) published 35 days ago (Sun Oct 12 2025)",
"limits 3.3.71 (core)",
"marketplace 1.3.8 (core)",
"org 5.9.43 (core)",
"packaging 2.23.3 (user) published 9 days ago (Fri Nov 07 2025)",
"schema 3.3.88 (core)",
"settings 2.4.50 (core)",
"signups 2.6.54 (user) published 16 days ago (Sat Nov 01 2025)",
"sobject 1.4.79 (core)",
"telemetry 3.6.64 (core)",
"templates 56.3.71 (core)",
"trust 3.7.113 (core)",
"user 3.6.41 (core)",
"@salesforce/sfdx-plugin-lwc-test 1.2.1 (user) published 408 days ago (Fri Oct 04 2024)",
"@salesforce/sfdx-scanner 4.12.0 (user) published 202 days ago (Tue Apr 29 2025)",
"sfdmu 4.38.0 (user) published 323 days ago (Sat Dec 28 2024)"
]
}