Skip to content

Add public FunctionsErrorCode type #6344

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

Merged
merged 6 commits into from
Jun 21, 2022
Merged

Add public FunctionsErrorCode type #6344

merged 6 commits into from
Jun 21, 2022

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Jun 8, 2022

Add a public FunctionsErrorCode type that is prefixed with "functions/" to match the exact strings found in FunctionsError.Code.

This uses template literal types which were introduced in Typescript 4.1. This should be ok for most users I hope? 4.1 was released in Nov 2020.

Fixes #6281

@hsubox76 hsubox76 requested a review from allspain as a code owner June 8, 2022 18:32
@changeset-bot
Copy link

changeset-bot bot commented Jun 8, 2022

🦋 Changeset detected

Latest commit: 7664c1e

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

This PR includes changesets to release 3 packages
Name Type
@firebase/functions Patch
firebase Patch
@firebase/functions-compat 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

@hsubox76 hsubox76 requested a review from egilmorez as a code owner June 8, 2022 18:33
@hsubox76 hsubox76 requested a review from dwyfrequency June 8, 2022 18:37
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 8, 2022

Size Report 1

Affected Products

  • @firebase/analytics

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser18.9 kB19.1 kB+232 B (+1.2%)
    esm523.5 kB23.8 kB+232 B (+1.0%)
    main24.6 kB24.9 kB+232 B (+0.9%)
    module18.9 kB19.1 kB+232 B (+1.2%)
  • @firebase/app-check

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser25.3 kB25.1 kB-147 B (-0.6%)
    esm529.9 kB29.8 kB-153 B (-0.5%)
    main31.1 kB31.0 kB-155 B (-0.5%)
    module25.3 kB25.1 kB-147 B (-0.6%)
  • @firebase/auth

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser155 kB155 kB+199 B (+0.1%)
    cordova183 kB183 kB+195 B (+0.1%)
    esm5202 kB203 kB+195 B (+0.1%)
    main148 kB148 kB+195 B (+0.1%)
    module155 kB155 kB+199 B (+0.1%)
    react-native168 kB168 kB+195 B (+0.1%)
  • @firebase/auth-compat

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser20.2 kB20.2 kB+40 B (+0.2%)
    esm527.0 kB27.1 kB+40 B (+0.1%)
    main29.6 kB29.6 kB+40 B (+0.1%)
    module20.2 kB20.2 kB+40 B (+0.2%)
  • @firebase/auth/cordova

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser183 kB183 kB+195 B (+0.1%)
    module183 kB183 kB+195 B (+0.1%)
  • @firebase/auth/internal

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser166 kB166 kB+199 B (+0.1%)
    esm5216 kB216 kB+195 B (+0.1%)
    main183 kB183 kB+195 B (+0.1%)
    module166 kB166 kB+199 B (+0.1%)
  • @firebase/auth/react-native

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser168 kB168 kB+195 B (+0.1%)
    module168 kB168 kB+195 B (+0.1%)
  • @firebase/database

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser248 kB249 kB+1.17 kB (+0.5%)
    esm5276 kB277 kB+1.20 kB (+0.4%)
    main281 kB282 kB+1.20 kB (+0.4%)
    module248 kB249 kB+1.17 kB (+0.5%)
  • @firebase/database-compat/standalone

    TypeBase (8340f84)Merge (1a979ca)Diff
    main370 kB371 kB+1.20 kB (+0.3%)
  • @firebase/firestore

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser257 kB262 kB+4.88 kB (+1.9%)
    esm5319 kB325 kB+5.94 kB (+1.9%)
    main515 kB522 kB+6.33 kB (+1.2%)
    module257 kB262 kB+4.88 kB (+1.9%)
    react-native257 kB262 kB+4.88 kB (+1.9%)
  • @firebase/firestore-lite

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser80.5 kB80.5 kB+17 B (+0.0%)
    esm596.2 kB96.2 kB+17 B (+0.0%)
    main135 kB135 kB+79 B (+0.1%)
    module80.5 kB80.5 kB+17 B (+0.0%)
    react-native80.7 kB80.7 kB+17 B (+0.0%)
  • @firebase/installations

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser17.8 kB17.8 kB+1 B (+0.0%)
    esm522.9 kB22.9 kB+1 B (+0.0%)
    main23.8 kB23.8 kB+1 B (+0.0%)
    module17.8 kB17.8 kB+1 B (+0.0%)
  • @firebase/installations-compat

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser944 B945 B+1 B (+0.1%)
    esm51.16 kB1.16 kB+1 B (+0.1%)
    main1.48 kB1.49 kB+1 B (+0.1%)
    module944 B945 B+1 B (+0.1%)
  • @firebase/messaging

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser21.2 kB21.3 kB+159 B (+0.8%)
    esm526.5 kB26.7 kB+159 B (+0.6%)
    main27.2 kB27.4 kB+159 B (+0.6%)
    module21.2 kB21.3 kB+159 B (+0.8%)
  • @firebase/messaging-sw

    TypeBase (8340f84)Merge (1a979ca)Diff
    main29.9 kB30.1 kB+159 B (+0.5%)
    module23.2 kB23.3 kB+159 B (+0.7%)
  • @firebase/performance

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser29.1 kB29.1 kB+1 B (+0.0%)
    esm530.8 kB30.8 kB+1 B (+0.0%)
    main31.2 kB31.2 kB+1 B (+0.0%)
    module29.1 kB29.1 kB+1 B (+0.0%)
  • @firebase/performance-compat

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser1.10 kB1.10 kB+1 B (+0.1%)
    esm51.37 kB1.38 kB+1 B (+0.1%)
    main1.69 kB1.69 kB+1 B (+0.1%)
    module1.10 kB1.10 kB+1 B (+0.1%)
  • @firebase/remote-config-compat

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser1.85 kB1.85 kB+1 B (+0.1%)
    esm52.76 kB2.76 kB+1 B (+0.0%)
    main3.09 kB3.09 kB+1 B (+0.0%)
    module1.85 kB1.85 kB+1 B (+0.1%)
  • @firebase/util

    TypeBase (8340f84)Merge (1a979ca)Diff
    browser20.5 kB20.7 kB+168 B (+0.8%)
    esm521.9 kB22.0 kB+172 B (+0.8%)
    main26.7 kB26.9 kB+226 B (+0.8%)
    module20.5 kB20.7 kB+168 B (+0.8%)
  • bundle

    34 size changes

    TypeBase (8340f84)Merge (1a979ca)Diff
    analytics (logEvent)41.6 kB41.8 kB+189 B (+0.5%)
    app-check (CustomProvider)35.4 kB35.4 kB+7 B (+0.0%)
    app-check (ReCaptchaEnterpriseProvider)37.6 kB37.6 kB+7 B (+0.0%)
    app-check (ReCaptchaV3Provider)37.5 kB37.5 kB+7 B (+0.0%)
    auth (Anonymous)66.2 kB66.3 kB+129 B (+0.2%)
    auth (EmailAndPassword)70.3 kB70.4 kB+129 B (+0.2%)
    auth (GoogleFBTwitterGitHubPopup)90.1 kB90.2 kB+139 B (+0.2%)
    auth (GooglePopup)89.9 kB90.0 kB+139 B (+0.2%)
    auth (GoogleRedirect)90.0 kB90.2 kB+139 B (+0.2%)
    auth (Phone)76.2 kB76.4 kB+129 B (+0.2%)
    database (Append to a list of data)145 kB145 kB-40 B (-0.0%)
    database (Filtering data)144 kB144 kB-40 B (-0.0%)
    database (Listen for child events)160 kB160 kB+218 B (+0.1%)
    database (Listen for value events + Detach listeners)160 kB160 kB+218 B (+0.1%)
    database (Listen for value events)160 kB160 kB+218 B (+0.1%)
    database (Read data once)152 kB157 kB+5.18 kB (+3.4%)
    database (Save data as transactions)162 kB162 kB+218 B (+0.1%)
    database (Sort data)146 kB146 kB-40 B (-0.0%)
    database (Write data)144 kB144 kB-40 B (-0.0%)
    firestore (Persistence)269 kB273 kB+4.76 kB (+1.8%)
    firestore (Query Cursors)208 kB210 kB+2.29 kB (+1.1%)
    firestore (Query)209 kB211 kB+2.29 kB (+1.1%)
    firestore (Read data once)197 kB200 kB+2.29 kB (+1.2%)
    firestore (Realtime updates)200 kB202 kB+2.29 kB (+1.1%)
    firestore (Transaction)181 kB184 kB+2.18 kB (+1.2%)
    firestore (Write data)181 kB183 kB+2.41 kB (+1.3%)
    firestore-lite (Query Cursors)208 kB210 kB+2.29 kB (+1.1%)
    firestore-lite (Query)208 kB210 kB+2.29 kB (+1.1%)
    firestore-lite (Read data once)197 kB200 kB+2.29 kB (+1.2%)
    firestore-lite (Transaction)181 kB184 kB+2.18 kB (+1.2%)
    firestore-lite (Write data)181 kB183 kB+2.41 kB (+1.3%)
    messaging (send + receive)45.0 kB45.1 kB+148 B (+0.3%)
    performance (trace)49.6 kB49.6 kB+2 B (+0.0%)
    remote-config (getAndFetch)44.2 kB44.2 kB+1 B (+0.0%)

  • firebase

    26 size changes

    TypeBase (8340f84)Merge (1a979ca)Diff
    firebase-analytics-compat.js25.6 kB25.8 kB+178 B (+0.7%)
    firebase-analytics.js111 kB112 kB+334 B (+0.3%)
    firebase-app-check-compat.js22.8 kB22.8 kB+27 B (+0.1%)
    firebase-app-check.js90.2 kB90.9 kB+689 B (+0.8%)
    firebase-app.js87.6 kB87.6 kB+20 B (+0.0%)
    firebase-auth-compat.js125 kB125 kB+172 B (+0.1%)
    firebase-auth-cordova.js472 kB472 kB+307 B (+0.1%)
    firebase-auth-react-native.js495 kB496 kB+1.30 kB (+0.3%)
    firebase-auth.js417 kB418 kB+331 B (+0.1%)
    firebase-compat.js788 kB794 kB+5.97 kB (+0.8%)
    firebase-database-compat.js166 kB166 kB+588 B (+0.4%)
    firebase-database.js604 kB607 kB+2.62 kB (+0.4%)
    firebase-firestore-compat.js309 kB314 kB+4.77 kB (+1.5%)
    firebase-firestore-lite.js837 kB845 kB+8.12 kB (+1.0%)
    firebase-firestore.js837 kB845 kB+8.12 kB (+1.0%)
    firebase-functions.js32.0 kB32.1 kB+20 B (+0.1%)
    firebase-messaging-compat.js38.0 kB38.2 kB+235 B (+0.6%)
    firebase-messaging-sw.js107 kB107 kB+234 B (+0.2%)
    firebase-messaging.js106 kB106 kB+234 B (+0.2%)
    firebase-performance-compat.js30.7 kB30.7 kB+3 B (+0.0%)
    firebase-performance-standalone-compat.es2017.js87.5 kB87.5 kB+4 B (+0.0%)
    firebase-performance-standalone-compat.js65.3 kB65.3 kB+3 B (+0.0%)
    firebase-performance.js123 kB123 kB+22 B (+0.0%)
    firebase-remote-config-compat.js27.3 kB27.3 kB+2 B (+0.0%)
    firebase-remote-config.js113 kB113 kB+21 B (+0.0%)
    firebase-storage.js146 kB146 kB+20 B (+0.0%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 8, 2022

Size Analysis Report 1

This report is too large (930,087 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/d9qN7tFkRU.html

Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

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

Question for you, thanks!

@@ -72,6 +72,30 @@ export interface Functions {
customDomain: string | null;
}

/**
* Functions error code string before adding "functions/" product prefix.
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it sound like the strings come before the prefix -- is that right?

Also, why specifically "product prefix?" Would that mean something like "functions/firestore?"

If we have a staged version of this, that could help me grok it I think.

Copy link
Contributor Author

@hsubox76 hsubox76 Jun 13, 2022

Choose a reason for hiding this comment

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

Staging it won't add anything that isn't here, unfortunately. Users were reporting that in v8, error codes were coming back as, for example, "deadline-exceeded" (one of the possible strings here) and in v9 they are coming back (more correctly) as "functions/deadline-exceeded" (since this is the functions package). We try to put a prefix with the SDK package name and a "/" before every error thrown by that SDK package. So Firestore should be throwing errors with code "firestore/something", auth should be throwing errors with code "auth/something", etc.

Lines 99-132 below have the main documentation for this code since that's the actual error code (with the prefix added) that users will see.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

So yes, if this is how it works, I'd expect something more like "* Functions error code string following the "functions/" product prefix."

or maybe "* Functions error code string appended after "functions/" product prefix."

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. I've changed it to "appended after".

Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@dwyfrequency dwyfrequency left a comment

Choose a reason for hiding this comment

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

LGTM

@hsubox76 hsubox76 merged commit e673dc8 into master Jun 21, 2022
@hsubox76 hsubox76 deleted the ch-functions-type branch June 21, 2022 21:51
This was referenced Jul 6, 2022
@firebase firebase locked and limited conversation to collaborators Jul 22, 2022
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.

httpsCallable error code format change from v8 to v9 should be warned loudly
4 participants