Skip to content

Make the FunctionsError class publicly exported #8546

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 10 commits into from
Oct 15, 2024
Merged

Conversation

dlarocque
Copy link
Contributor

@dlarocque dlarocque commented Sep 30, 2024

We should export the FunctionsError class to users, so that they can perform instanceof checks.

Tested using:

import { FirebaseError, initializeApp } from "firebase/app";
import { FunctionsError, getFunctions, httpsCallable } from "firebase/functions";

const firebaseConfig = {
  /* ... */
};

const app = initializeApp(firebaseConfig);
const functions = getFunctions(app);
(async () => {
  try {
    const addMessage = httpsCallable(functions, 'addMessage'); // Function does not exist
    await addMessage({ text: 'hello' });
  } catch (err) {
    console.log(err instanceof FirebaseError); // true
    console.log(err instanceof FunctionsError); // true
    throw err;
  }
})();

Also added an expect(error).to.be.instanceOf(FunctionsError) to all error checks in the tests.

Fixes #8511

@dlarocque dlarocque requested a review from hsubox76 September 30, 2024 16:21
@dlarocque dlarocque requested review from a team as code owners September 30, 2024 16:21
Copy link

changeset-bot bot commented Sep 30, 2024

🦋 Changeset detected

Latest commit: 2aa4f34

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

@dlarocque dlarocque changed the title Make the FunctionsError class publicly exported. Make the FunctionsError class publicly exported Sep 30, 2024
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 30, 2024

Size Report 1

Affected Products

  • @firebase/data-connect

    TypeBase (beaa4df)Merge (c351ba6)Diff
    browser19.8 kB19.8 kB-1 B (-0.0%)
    esm522.5 kB22.5 kB-1 B (-0.0%)
    main24.3 kB24.3 kB-1 B (-0.0%)
    module19.8 kB19.8 kB-1 B (-0.0%)
  • @firebase/functions

    TypeBase (beaa4df)Merge (c351ba6)Diff
    browser9.76 kB9.83 kB+68 B (+0.7%)
    esm512.1 kB12.2 kB+69 B (+0.6%)
    main12.8 kB12.9 kB+155 B (+1.2%)
    module9.76 kB9.83 kB+68 B (+0.7%)
  • @firebase/messaging

    TypeBase (beaa4df)Merge (c351ba6)Diff
    browser21.3 kB21.3 kB-84 B (-0.4%)
    esm526.8 kB26.7 kB-84 B (-0.3%)
    main27.4 kB27.4 kB-84 B (-0.3%)
    module21.3 kB21.3 kB-84 B (-0.4%)
  • @firebase/messaging-sw

    TypeBase (beaa4df)Merge (c351ba6)Diff
    main30.4 kB30.4 kB-59 B (-0.2%)
    module23.6 kB23.5 kB-59 B (-0.3%)
  • bundle

    TypeBase (beaa4df)Merge (c351ba6)Diff
    functions (call)32.0 kB32.1 kB+41 B (+0.1%)
    messaging (send + receive)47.0 kB46.9 kB-73 B (-0.2%)
  • firebase

    TypeBase (beaa4df)Merge (c351ba6)Diff
    firebase-compat.js788 kB788 kB-102 B (-0.0%)
    firebase-data-connect.js16.5 kB16.5 kB-1 B (-0.0%)
    firebase-functions-compat.js8.22 kB8.26 kB+40 B (+0.5%)
    firebase-functions.js12.0 kB12.0 kB+68 B (+0.6%)
    firebase-messaging-compat.js38.4 kB38.3 kB-143 B (-0.4%)
    firebase-messaging-sw.js30.2 kB30.1 kB-71 B (-0.2%)
    firebase-messaging.js28.7 kB28.7 kB-96 B (-0.3%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 30, 2024

Size Analysis Report 1

Affected Products

  • @firebase/data-connect

    • DataConnect

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • MUTATION_STR

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • MutationManager

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • QUERY_STR

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • SOURCE_CACHE

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • SOURCE_SERVER

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • connectDataConnectEmulator

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.7 kB29.7 kB-1 B (-0.0%)
    • executeMutation

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.7 kB29.7 kB-1 B (-0.0%)
    • executeQuery

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.7 kB29.7 kB-1 B (-0.0%)
    • getDataConnect

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.2 kB12.2 kB-1 B (-0.0%)
      size-with-ext-deps37.4 kB37.4 kB-1 B (-0.0%)
    • mutationRef

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.7 kB29.7 kB-1 B (-0.0%)
    • parseOptions

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.5 kB11.5 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • queryRef

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.7 kB29.7 kB-1 B (-0.0%)
    • setLogLevel

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • subscribe

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.8 kB12.8 kB-1 B (-0.0%)
      size-with-ext-deps37.9 kB37.9 kB-1 B (-0.0%)
    • terminate

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.6 kB11.6 kB-1 B (-0.0%)
      size-with-ext-deps29.6 kB29.6 kB-1 B (-0.0%)
    • toQueryRef

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.4 kB12.4 kB-1 B (-0.0%)
      size-with-ext-deps37.6 kB37.6 kB-1 B (-0.0%)
    • validateArgs

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.4 kB12.4 kB-1 B (-0.0%)
      size-with-ext-deps37.5 kB37.5 kB-1 B (-0.0%)
    • validateDCOptions

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size11.8 kB11.8 kB-1 B (-0.0%)
      size-with-ext-deps29.8 kB29.8 kB-1 B (-0.0%)
  • @firebase/functions

    • FunctionsError

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size?2.52 kB? (?)
      size-with-ext-deps?20.3 kB? (?)

      Dependency

      TypeBase (beaa4df)Merge (c351ba6)Diff
      functions?

      registerFunctions

      ?
      classes?

      ContextProvider
      FunctionsError
      FunctionsService

      ?
      variables?

      APP_CHECK_INTERNAL_NAME
      AUTH_INTERNAL_NAME
      DEFAULT_REGION
      FUNCTIONS_TYPE
      MESSAGING_INTERNAL_NAME
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (beaa4df)Merge (c351ba6)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • httpsCallable

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size6.13 kB6.17 kB+40 B (+0.7%)
      size-with-ext-deps24.0 kB24.1 kB+41 B (+0.2%)
    • httpsCallableFromURL

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size6.08 kB6.12 kB+40 B (+0.7%)
      size-with-ext-deps24.0 kB24.0 kB+41 B (+0.2%)
  • @firebase/messaging

    • deleteToken

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.7 kB12.7 kB-72 B (-0.6%)
      size-with-ext-deps39.5 kB39.4 kB-73 B (-0.2%)
    • getMessaging

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.8 kB12.7 kB-73 B (-0.6%)
      size-with-ext-deps46.7 kB46.6 kB-73 B (-0.2%)
    • getToken

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.2 kB12.2 kB-72 B (-0.6%)
      size-with-ext-deps39.0 kB38.9 kB-73 B (-0.2%)
    • isSupported

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.6 kB12.5 kB-72 B (-0.6%)
      size-with-ext-deps39.3 kB39.2 kB-73 B (-0.2%)
    • onMessage

      Size

      TypeBase (beaa4df)Merge (c351ba6)Diff
      size12.4 kB12.3 kB-72 B (-0.6%)
      size-with-ext-deps39.1 kB39.0 kB-73 B (-0.2%)

Test Logs

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

@dlarocque dlarocque requested a review from egilmorez October 3, 2024 15:50
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.

LG with tiny nits, thanks!

Copy link
Contributor

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_vertexai_responses.sh should be updated to clone the latest version of the responses: v4.0

@dlarocque dlarocque merged commit a214691 into main Oct 15, 2024
38 of 39 checks passed
@dlarocque dlarocque deleted the dl/functions-error branch October 15, 2024 14:57
@google-oss-bot google-oss-bot mentioned this pull request Oct 17, 2024
@firebase firebase locked and limited conversation to collaborators Nov 15, 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.

FunctionsError exported as a type only, but implementation exists
4 participants