Skip to content

Handling responses with fetchLater #96

@DerGernTod

Description

@DerGernTod

I'm having a hard time understanding why the current implementation of fetchLater doesn't yield any response. I understand that it doesn't make sense if the context is already gone (similar to sendBeacon only yielding a bool), but what if the context is not gone and the response is actually interesting? Imho this is the most important part of fetch keepAlive: you can use the fetch api the same way you used to and don't have to fall back to sendBeacon if you decide to send during unload, especially if you started sending and during the request, the page unloads. with fetch keepAlive you're safe. Without keepAlive, if you send the request before the unload event, you never have the chance to decide to send with sendBeacon. So for us, keepAlive resolved this issue completely.

However, with fetchLater, the whole issue comes back. Our implementation leverages beacons to retrieve monitoring configuration updates (which of course can be ignored if the page is already gone, but is important if the page is still active, say for SPAs that aren't reloaded for hours or days). Thus we still have to fall back to fetch keepAlive and cannot leverage fetchLater at all for our beacons. We would fire request solely for config updates every now and then, and use fetchLater for beacons, but that would cause additional requests for no gain (in 99% of the cases, the config stays the same).

Can someone explain to me the narrative as to why fetchLater never yields a response?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions