Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable keepalive for error fetch requests #7546

Closed
mydea opened this issue Mar 21, 2023 · 0 comments · Fixed by #7553
Closed

Disable keepalive for error fetch requests #7546

mydea opened this issue Mar 21, 2023 · 0 comments · Fixed by #7553
Assignees

Comments

@mydea
Copy link
Member

mydea commented Mar 21, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant