Loading

Revenue Cloud: Intermittent Apex CPU Time Limit Exception When Testing Quote Repricing via Pricing/Sales Transaction Framework

Fecha de publicación: Sep 25, 2026
Descripción

Customers using a custom Apex invocable class to invoke quote repricing through the Place Sales Transaction execution path may observe an intermittent System.LimitException: Apex CPU time limit exceeded error specifically during unit test execution of that method, while the identical method executed live (via Execute Anonymous or normal application flow) consistently completes within a few seconds.

Debug log analysis shows the majority of CPU time is consumed within the underlying pricing execution framework rather than in the custom extension logic for pricing. Log comparisons between live and test execution reveal that the pricing framework experiences cache misses in the test context that do not occur in live execution, adding several seconds of processing overhead.

Apex test execution runs in an isolated transaction context, cached data available during live execution (such as pricing/business rule caches) is not available, resulting in longer execution and higher CPU consumption. This behavior has been observed across multiple environments and does not correlate with a specific custom configuration or code change, making it appear intermittent.

Solución

This has been confirmed as expected platform behavior tied to test-context cache isolation, not a code defect. As a workaround, avoid asserting on strict CPU time thresholds within unit tests that exercise the pricing/repricing execution path, since test-context timing will differ from live execution.

Where possible, reduce the volume/complexity of data used in the test scenario, And isolate the repricing call so it can be tested with smaller scope, to reduce the chance of intermittently exceeding the synchronous Apex CPU limit during test runs.

Note : Place Sales Transaction apex execution can not provide runtime guarantees with Config and Pricing preferences set to System/Force within the PST payload and ideal unit tests for the same can be performed with setting these preferences to Skip. 

Número del artículo de conocimiento

005460598

 
Cargando
Salesforce Help | Article