3 ms·
> The bug in this implementation is that if sendOnce is called consecutively and the previous request hasn't finished yet, then we violate the "one request at a
by xg15 1y ago
> The bug in this implementation is that if sendOnce is called consecutively and the previous request hasn't finished yet, then we violate the "one request at a time" requirement.
Maybe I haven't had enough coffee yet, but the "naive" implementation looks like it wouldn't use the queue at all, regardless how quickly or slowly you fire off the requests.
The code is literally
if (requestQueue.length === 0) {
...
}
else {
requestQueue.push(...)
}
with no other push() anywhere else. So how would the queue ever get nonempty in the first place?