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

[documentation]: explain keepalive #780

Closed
JonasBa opened this issue Jun 4, 2020 · 1 comment
Closed

[documentation]: explain keepalive #780

JonasBa opened this issue Jun 4, 2020 · 1 comment

Comments

@JonasBa
Copy link

JonasBa commented Jun 4, 2020

While researching fetch polyfills, I found the keepalive option, which indicates that the request may outlive the current page context.

As a library author, I'm looking for good ways to rely on fetch support (polyfilled or not) so that my library can send data. I wanted to check what happens when a polyfill is applied and keepalive is provided (either true or false), because in the event that keepalive: true is set, I do not want the polyfilled code to send a synchronous XHR request and penalize UX.

Since this is a very widely adopted polyfill, I wanted to understand how it handles keepalive (if at all) but I could not find any documentation.

I assume that because the underlying keepalive connection is handled in the background, the polyfill cannot do anything about it and thus, in the case of keepalive: true, the connection is terminated by the browser as the page context is close and the request is not sent synchronously.

In pseudo code, I want to know if should check for fetch support via

if(fetch.toString().indexOf("[native code]") > -1){
  fetch({..., keepalive: true}) // we can be sure this will never be synchronous
}

vs

if(typeof fetch === "function"{
  fetch({..., keepalive: true}) // this might be sync, depending on the polyfill
}

I realize that there can be many different polyfills with varying implementations and it might be always best to rely on native code implementation in my case, but whatever the case, I would love to help you add a paragraph or two to the documentation at least for people to know how keepalive is supported via this polyfill :)

@JakeChampion
Copy link
Owner

Yes, we are more than happy for someone to contribute documentation on this. We do not offer keepalive because we do not want to add synchronous XHR to this polyfill. Here is a previous discussion on this (Before I was a maintainer on this project) -- #700 (comment)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 7, 2021
cr313 added a commit to cr313/fetch-Js-flow that referenced this issue Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@JakeChampion @JonasBa and others