Hi again!
So it looks like because of the way the POST method is set up, the outQueue is "flushed" (events that were sent are removed/shift()ed from the queue) only in the onreadystatechange handler.
for (var deleteCount = 0; deleteCount < numberToSend; deleteCount++) {
outQueue.shift();
}
Because the beacon API hands off control to the browser, there's no onreadystatechange or similar callback - you just make the sendBeacon() call, and get the true back, which is the browser telling you it queued the call.
As a result, I've had instances where the outQueue just increases to infinite length over time, since it's saved to localStorage and then picked back up
The solution seems to be break this out into logic that's called from both places - let me know if my solution (Pull Request #709) works for you
Hi again!
So it looks like because of the way the POST method is set up, the
outQueueis "flushed" (events that were sent are removed/shift()ed from the queue) only in theonreadystatechangehandler.Because the beacon API hands off control to the browser, there's no
onreadystatechangeor similar callback - you just make thesendBeacon()call, and get thetrueback, which is the browser telling you it queued the call.As a result, I've had instances where the outQueue just increases to infinite length over time, since it's saved to localStorage and then picked back up
The solution seems to be break this out into logic that's called from both places - let me know if my solution (Pull Request #709) works for you