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

Remove referrerPolicy from Cloudflare Worker fetch requests #8393

Merged
merged 14 commits into from
Sep 11, 2024

Conversation

DellaBitta
Copy link
Contributor

@DellaBitta DellaBitta commented Jul 25, 2024

Discussion

The Cloudflare Worker runner runtime doesn't support the fetch parameter referrerPolicy and throws if one is defined. In attempt to better support Cloudlfare, we will remove this parameter from fetch requests when we detect the SDK is running in a Cloudflare runner environment.

Fixes #8355.

Testing

CI. Updated unit tests to test if referrerPolicy is omitted if isCloudflareWorker() returns true.

API Changes

N/A.

Copy link

changeset-bot bot commented Jul 25, 2024

🦋 Changeset detected

Latest commit: b1f3860

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

This PR includes changesets to release 29 packages
Name Type
@firebase/auth Patch
@firebase/util Minor
@firebase/auth-compat Patch
firebase Patch
@firebase/firestore Patch
@firebase/storage Patch
@firebase/analytics-compat Patch
@firebase/analytics Patch
@firebase/app-check-compat Patch
@firebase/app-check Patch
@firebase/app-compat Patch
@firebase/app Patch
@firebase/component Patch
@firebase/database-compat Patch
@firebase/database-types Patch
@firebase/database Patch
@firebase/firestore-compat Patch
@firebase/functions-compat Patch
@firebase/functions Patch
@firebase/installations-compat Patch
@firebase/installations Patch
@firebase/messaging-compat Patch
@firebase/messaging Patch
@firebase/performance-compat Patch
@firebase/performance Patch
@firebase/remote-config-compat Patch
@firebase/remote-config Patch
@firebase/storage-compat Patch
@firebase/vertexai-preview 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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 25, 2024

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (15c36cc)Merge (f94187a)Diff
    browser182 kB182 kB+81 B (+0.0%)
    cordova209 kB209 kB+85 B (+0.0%)
    esm5236 kB236 kB+85 B (+0.0%)
    main179 kB179 kB+71 B (+0.0%)
    module182 kB182 kB+81 B (+0.0%)
    react-native199 kB199 kB+71 B (+0.0%)
  • @firebase/auth-cordova

    TypeBase (15c36cc)Merge (f94187a)Diff
    browser209 kB209 kB+85 B (+0.0%)
    module209 kB209 kB+85 B (+0.0%)
  • @firebase/auth-web-extension

    TypeBase (15c36cc)Merge (f94187a)Diff
    browser137 kB137 kB+81 B (+0.1%)
    main152 kB152 kB+69 B (+0.0%)
    module137 kB137 kB+81 B (+0.1%)
  • @firebase/auth/internal

    TypeBase (15c36cc)Merge (f94187a)Diff
    browser193 kB193 kB+81 B (+0.0%)
    esm5249 kB249 kB+85 B (+0.0%)
    main214 kB214 kB+73 B (+0.0%)
    module193 kB193 kB+81 B (+0.0%)
  • @firebase/util

    TypeBase (15c36cc)Merge (f94187a)Diff
    browser23.2 kB23.4 kB+131 B (+0.6%)
    esm524.9 kB25.0 kB+131 B (+0.5%)
    main30.7 kB30.9 kB+233 B (+0.8%)
    module23.2 kB23.4 kB+131 B (+0.6%)
  • bundle

    TypeBase (15c36cc)Merge (f94187a)Diff
    auth (Anonymous)76.1 kB76.2 kB+119 B (+0.2%)
    auth (EmailAndPassword)84.4 kB84.5 kB+119 B (+0.1%)
    auth (GoogleFBTwitterGitHubPopup)103 kB103 kB+118 B (+0.1%)
    auth (GooglePopup)100 kB100 kB+119 B (+0.1%)
    auth (GoogleRedirect)100 kB100 kB+119 B (+0.1%)
    auth (Phone)86.8 kB86.9 kB+119 B (+0.1%)
  • firebase

    TypeBase (15c36cc)Merge (f94187a)Diff
    firebase-app.js103 kB103 kB+2 B (+0.0%)
    firebase-auth-compat.js139 kB139 kB+88 B (+0.1%)
    firebase-auth-cordova.js177 kB177 kB+124 B (+0.1%)
    firebase-auth-web-extension.js117 kB117 kB+128 B (+0.1%)
    firebase-auth.js151 kB151 kB+128 B (+0.1%)
    firebase-compat.js788 kB788 kB+88 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/C7OjlHWcnr.html

@firebase firebase deleted a comment from google-oss-bot Sep 5, 2024
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 5, 2024

Size Analysis Report 1

This report is too large (126,839 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/DYMh2MXeZL.html

@DellaBitta DellaBitta changed the title WIP remove referrerPolicy from fetch requests Remove referrerPolicy from Cloudflare Worker fetch requests Sep 5, 2024
@DellaBitta DellaBitta marked this pull request as ready for review September 5, 2024 16:03
@NhienLam NhienLam self-requested a review September 5, 2024 17:59
@@ -0,0 +1,7 @@
---
'@firebase/auth': minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a minor for auth? The API doesn't change. I don't think we bump automatically based on dependencies' bump level. I'm not totally sure if changesets does it but I think it also doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, switched Auth to a patch bump instead of a minor bump.

@DellaBitta DellaBitta requested a review from hsubox76 September 6, 2024 00:53
Copy link
Contributor

github-actions bot commented Sep 6, 2024

Changeset File Check ⚠️

  • Package @firebase/util has a minor bump which requires an additional line to bump the main "firebase" package to minor.

@@ -148,14 +148,19 @@ export async function _performApiRequest<T, V>(
headers[HttpHeader.X_FIREBASE_LOCALE] = auth.languageCode;
}

const fetchArgs: RequestInit = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider adding some unit tests on _performApiRequest since we introduced new logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

.changeset/khaki-numbers-nail.md Outdated Show resolved Hide resolved
packages/auth/src/api/index.ts Show resolved Hide resolved
if (request !== undefined && request.referrerPolicy !== undefined) {
referrerPolicySet = true;
}
return new Promise<never>((_, reject) =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: possible to resolve the promise instead of reject?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious why these tests have a rejected promise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Updated tests so that these mocks resolve.

@DellaBitta DellaBitta merged commit 16d62d4 into main Sep 11, 2024
42 of 43 checks passed
@DellaBitta DellaBitta deleted the ddb-remove-referrerpolicy branch September 11, 2024 00:40
@google-oss-bot google-oss-bot mentioned this pull request Sep 16, 2024
dlarocque pushed a commit that referenced this pull request Sep 16, 2024
The Cloudflare Worker runner runtime doesn't support the `fetch` parameter `referrerPolicy` and throws if one is defined. In attempt to better support Cloudlfare, we will remove this parameter from `fetch` requests when we detect the SDK running in a Cloudflare runner enviornment.
@firebase firebase locked and limited conversation to collaborators Oct 11, 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

Successfully merging this pull request may close these issues.

Server App Not Logging In
5 participants