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
Hello, guys, I started to use your library and found a pretty nasty bug in FacebookAdsApiBatch.
In the constructor we could pass successCallback as a parameter, so it'll be saved in the pool of callbacks:
constructor (
api: FacebookAdsApi,
successCallback?: Function,
failureCallback?: Function
) {
...
if (successCallback != null) {
this._successCallbacks.push(successCallback);
}
if (failureCallback != null) {
this._failureCallbacks.push(failureCallback);
}
}
When we're adding requests to the batch, we could pass successCallback as well, but during execution callbacks applied from the common pool of callbacks (including general success callback, which we passed in constructor):
for (let index = 0; index < responses.length; index++) {
const response = responses[index];
if (response != null) {
const apiResponse = new APIResponse(response, this._batch[index]);
// Call the success callback if provided
if (apiResponse.isSuccess) {
if (this._successCallbacks[index]) {
this._successCallbacks[index](apiResponse);
}
} else {
// Call the failure callback if provided
if (this._failureCallbacks[index]) {
this._failureCallbacks[index](apiResponse);
}
}
} else {
// Do not get response, so, we keep track of the index to retry
retryIndices.push(index);
}
}
So here index is an index of response, but when we add general success callback, amount of callbacks will be always response.length + 1, so last success callback will never be called.
And it seems the same situation with failureCallbacks.
The text was updated successfully, but these errors were encountered:
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Hello, guys, I started to use your library and found a pretty nasty bug in
FacebookAdsApiBatch
.In the constructor we could pass
successCallback
as a parameter, so it'll be saved in the pool of callbacks:When we're adding requests to the batch, we could pass
successCallback
as well, but during execution callbacks applied from the common pool of callbacks (including general success callback, which we passed in constructor):So here
index
is an index of response, but when we add general success callback, amount of callbacks will be alwaysresponse.length + 1
, so last success callback will never be called.And it seems the same situation with
failureCallbacks
.The text was updated successfully, but these errors were encountered: