firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

Switched firebase/database to use the `fetch()` api

Open betabites opened this issue 7 months ago • 5 comments

Switched out the usage of XMLHttpRequest in @firebase/database for primitives from the more modern and better-supported Fetch API.

betabites avatar May 15 '25 05:05 betabites

🦋 Changeset detected

Latest commit: b3cb3994fec2d27a684c84f2ee1b383c3c6e76b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/database Patch
@firebase/database-compat Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar May 15 '25 05:05 changeset-bot[bot]

I am a bit intrigued by this part "better-supported" What exactly does that mean, better supported by who/what?

Smrtnyk avatar May 25 '25 10:05 Smrtnyk

Yeah I could've worded that better. Essentially - correct me if I'm wrong - but in modern cases, fetch is supported in all contexts where XMLHttpRequest is, plus a few additional ones. You can view the MDN docs for XMLHttpRequest and fetch for more information on availability.

Long story short: In addition, the fetch API is also supported on service workers and server-side environments such as Deno and NodeJS. Using the Fetch API potentially widens support, while also reducing code complexity.

By 'better supported', I simply mean there's slightly more environments where the Fetch API is officially adopted & supported.

betabites avatar May 26 '25 01:05 betabites

Yeah I could've worded that better. Essentially - correct me if I'm wrong - but in modern cases, fetch is supported in all contexts where XMLHttpRequest is, plus a few additional ones. You can view the MDN docs for XMLHttpRequest and fetch for more information on availability.

Long story short: In addition, the fetch API is also supported on service workers and server-side environments such as Deno and NodeJS. Using the Fetch API potentially widens support, while also reducing code complexity.

By 'better supported', I simply mean there's slightly more environments where the Fetch API is officially adopted & supported.

gotcha, tnx for the explanation was just curious what it exactly meant in this context of the PR

Smrtnyk avatar May 26 '25 05:05 Smrtnyk

Oh right yeah. As mentioned, fetch has slightly better support across platforms and an arguably more readable API. This PR intends to switch @firebase/database to use fetch instead, as it's more readable and has improved cross-platform support.

betabites avatar May 26 '25 21:05 betabites