You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that sometimes when I am performing some action when a promise comes back from some kind of request - it is possible that the request will hand back a promise that does not belong to the current request (the one I expect will be evaluated). For example:
returnforce.query('SELECT Id, FROM PricebookEntry').then(function(response){pricebookentries=response.records;});returnforce.query('SELECT Id, FROM Account').then(function(response){accounts=response.records;});
If I perform these two queries in parallel - I have seen times where the response callback for the Account query will return the results from the PricebookEntry query. It's like the wires are getting crossed. I got around the problem by doing each successive call in a .then() block but that doesn't seem ideal.
Looking at the forceng source - I see this in the code:
functionrequest(obj){if(!oauth||(!oauth.access_token&&!oauth.refresh_token)){deferred.reject('No access token. Login and try again.');return;}varmethod=obj.method||'GET',headers={},url=getRequestBaseURL();deferred=$q.defer();
Notice that the deferred is defined as a window variable (not var). So the deferred is actually shared across requests, which is interesting - and looks to be by design. Can you explain if this is the case and it is indeed supposed to operate like that? And if so, how to best perform multiple asynchronous requests without worrying about getting information for another request during promise resolve?
Thanks!
The text was updated successfully, but these errors were encountered:
I've noticed that sometimes when I am performing some action when a promise comes back from some kind of request - it is possible that the request will hand back a promise that does not belong to the current request (the one I expect will be evaluated). For example:
If I perform these two queries in parallel - I have seen times where the response callback for the Account query will return the results from the PricebookEntry query. It's like the wires are getting crossed. I got around the problem by doing each successive call in a .then() block but that doesn't seem ideal.
Looking at the forceng source - I see this in the code:
Notice that the deferred is defined as a window variable (not var). So the deferred is actually shared across requests, which is interesting - and looks to be by design. Can you explain if this is the case and it is indeed supposed to operate like that? And if so, how to best perform multiple asynchronous requests without worrying about getting information for another request during promise resolve?
Thanks!
The text was updated successfully, but these errors were encountered: