Closed
Description
We have introduced keepalive
in #5697. However, there have been some reports (e.g. #6049) that users have pending HTTP requests, probably due to this.
We should set this flag to false
for error events, and only set this flag for replays and transactions, as they have the characteristic:
- It is more likely to be fired right before leaving the page
- It is not likely to have multiple of these requests in parallel (for replay, you only ever have one pending request)
For errors, in contrast, you can have many at the same time, and it's not so likely to have (relevant) errors right before a page is switched.
This is IMHO the best tradeoff overall.
Reproduction
We could reproduce this with the following code:
for (let i = 0; i < 60; i++) {
Sentry.captureException(`test exception ${i}`);
}
Some of the sentry request will remain pending
forever in Chrome.
note that other fetch requests to other domains do go through. Still, this is not ideal.
Observations
- The promise buffer works at cutting requests off after 30 in flight requests (e.g. the above example only triggers 30 requests)
- It seems to work to make a lot of keepalive requests to other domains, e.g.:
for (let i = 0; i < 30; i++) {
fetch(`https://reqres.in/api/users/`, { method: 'POST', keepalive: true });
}
- The promise buffer detects the "pending" promises as failed, and successfully removes them from the buffer.
- Once we run into the pending scenario, most new requests are also pending (e.g. adding 30 more will only resolve 4, and 26 are pending)