In the code bellow, the third parameter is a promise, that when resolved (or rejected) will execute a callback function.

There we receive a "Maximum call stack size exceeded" when Locker service is active.

var dataService = {
request : $A.getCallback(function(actionName, params, defer) {

    var componentActionName = 'c.' + actionName;
    var action = component.get(componentActionName);


    action.setCallback(this, function(a) {
        try {

            var state = a.getState();
            if (state === 'SUCCESS') {
            else if (state === 'ERROR') {
                var errors = a.getError();
                if (errors) {
                } else {
                    defer.reject('Lightning server side unknown error');
        } catch (ex) {
            console.log('### Exception: ');



Any idea what might be going on?

  • Just an observation, you seem to be storing the result of $A.getCallback in an object which is not recommended in the developer guide: "Don't save a reference to a function wrapped in $A.getCallback(). If you use the reference later to send actions, the saved transaction state will cause the actions to be aborted." I don't know if that could be part of the problem or not.
    – Charles T
    Jun 30 '16 at 13:58

This has been fixed by Salesforce on SUMMER '16 PATCH 7.0

More details:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.