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

feat(browser): Use fetch keepalive flag #5697

Merged
merged 2 commits into from
Sep 6, 2022
Merged

Conversation

lforst
Copy link
Member

@lforst lforst commented Sep 6, 2022

While working on #5676 I noticed some navigation transactions don't show up in Sentry. I found out that when navigating between pages, Chrome cancels any outgoing requests - including requests to Sentry.

Events not being sent because of a page navigation probably happens the most with navigation transactions, since we usually finish the transaction right before we navigate (finishing happens implicitly on navigation). To requests being cancelled, we can use fetch's keepalive flag to keep outgoing requests alive, even when we're switching pages.

#2547 has an excellent writeup on the pros and cons of this flag. In short:

  • keepalive isn't supported by Firefox
  • As per specification, a fetch request with keepalive: true and a content length of > 64 kibibytes returns a network error

This change definitely isn't a solution to solve this problem in 100% of the cases but it is our best effort to improve the status quo.


Resolves #2547

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.43 KB (+0.06% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.11 KB (+0.06% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18 KB (+0.07% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 52.97 KB (+0.06% 🔺)
@sentry/browser - Webpack (gzipped + minified) 19.8 KB (+0.07% 🔺)
@sentry/browser - Webpack (minified) 64.36 KB (+0.05% 🔺)
@sentry/react - Webpack (gzipped + minified) 19.82 KB (+0.08% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.68 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.93 KB (+0.05% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.3 KB (+0.06% 🔺)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch KeepAlive
2 participants