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

Ensure errors are wrapped in FirestoreError in DatastoreImpl methods #4788

Merged
merged 10 commits into from
Apr 19, 2021

Conversation

dconeybe
Copy link
Contributor

Fixes: #4780

@changeset-bot
Copy link

changeset-bot bot commented Apr 14, 2021

🦋 Changeset detected

Latest commit: 7bbbfe5

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

This PR includes changesets to release 8 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/rules-unit-testing 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

@dconeybe dconeybe self-assigned this Apr 14, 2021
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 14, 2021

Size Analysis Report

Affected Products

No changes between base commit (03e97b8) and head commit (94499b3).

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 14, 2021

Binary Size Report

Affected SDKs

  • @firebase/analytics

    Type Base (03e97b8) Head (94499b3) Diff
    esm2017 ? 18.7 kB ? (?)
    main ? 24.2 kB ? (?)
    module ? 23.4 kB ? (?)
  • @firebase/app

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 10.8 kB ? (?)
    esm2017 ? 9.57 kB ? (?)
    lite ? 8.88 kB ? (?)
    lite-esm2017 ? 7.87 kB ? (?)
    main ? 9.93 kB ? (?)
    module ? 10.8 kB ? (?)
    react-native ? 9.64 kB ? (?)
  • @firebase/auth

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 181 kB ? (?)
    main ? 181 kB ? (?)
    module ? 181 kB ? (?)
  • @firebase/component

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 7.24 kB ? (?)
    esm2017 ? 5.55 kB ? (?)
    main ? 7.57 kB ? (?)
    module ? 7.24 kB ? (?)
  • @firebase/database

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 291 kB ? (?)
    esm2017 ? 261 kB ? (?)
    main ? 294 kB ? (?)
    module ? 291 kB ? (?)
  • @firebase/database-compat

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 84.3 kB ? (?)
    main ? 99.7 kB ? (?)
    module ? 84.3 kB ? (?)
  • @firebase/database-exp

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 242 kB ? (?)
    main ? 273 kB ? (?)
    module ? 242 kB ? (?)
  • @firebase/firestore

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 282 kB ? (?)
    esm2017 ? 225 kB ? (?)
    main ? 529 kB ? (?)
    module ? 282 kB ? (?)
    react-native ? 225 kB ? (?)
  • @firebase/firestore-compat

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 28.4 kB ? (?)
    main ? 37.4 kB ? (?)
    module ? 28.4 kB ? (?)
    react-native ? 28.1 kB ? (?)
  • @firebase/firestore-exp

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 223 kB ? (?)
    main ? 505 kB ? (?)
    module ? 223 kB ? (?)
    react-native ? 223 kB ? (?)
  • @firebase/firestore-lite

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 71.4 kB ? (?)
    main ? 145 kB ? (?)
    module ? 71.4 kB ? (?)
    react-native ? 71.6 kB ? (?)
  • @firebase/firestore/bundle

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 289 kB ? (?)
    esm2017 ? 175 kB ? (?)
    main ? 525 kB ? (?)
    module ? 289 kB ? (?)
    react-native ? 175 kB ? (?)
  • @firebase/firestore/memory

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 215 kB ? (?)
    esm2017 ? 171 kB ? (?)
    main ? 323 kB ? (?)
    module ? 215 kB ? (?)
    react-native ? 171 kB ? (?)
  • @firebase/firestore/memory-bundle

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 223 kB ? (?)
    esm2017 ? 175 kB ? (?)
    main ? 320 kB ? (?)
    module ? 223 kB ? (?)
    react-native ? 175 kB ? (?)
  • @firebase/functions

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 9.90 kB ? (?)
    esm2017 ? 7.71 kB ? (?)
    main ? 10.3 kB ? (?)
    module ? 9.90 kB ? (?)
  • @firebase/installations

    Type Base (03e97b8) Head (94499b3) Diff
    esm2017 ? 16.6 kB ? (?)
    main ? 22.2 kB ? (?)
    module ? 21.6 kB ? (?)
  • @firebase/logger

    Type Base (03e97b8) Head (94499b3) Diff
    esm2017 ? 3.25 kB ? (?)
    main ? 5.38 kB ? (?)
    module ? 4.65 kB ? (?)
  • @firebase/messaging

    Type Base (03e97b8) Head (94499b3) Diff
    esm2017 ? 26.2 kB ? (?)
    main ? 34.9 kB ? (?)
    module ? 34.4 kB ? (?)
  • @firebase/performance

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 27.7 kB ? (?)
    esm2017 ? 25.9 kB ? (?)
    main ? 28.0 kB ? (?)
    module ? 27.7 kB ? (?)
  • @firebase/polyfill

    Type Base (03e97b8) Head (94499b3) Diff
    main ? 747 B ? (?)
    module ? 705 B ? (?)
  • @firebase/remote-config

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 22.4 kB ? (?)
    esm2017 ? 17.4 kB ? (?)
    main ? 23.0 kB ? (?)
    module ? 22.4 kB ? (?)
  • @firebase/rules-unit-testing

    Type Base (03e97b8) Head (94499b3) Diff
    main ? 12.6 kB ? (?)
  • @firebase/storage

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 62.0 kB ? (?)
    esm2017 ? 53.6 kB ? (?)
    main ? 62.5 kB ? (?)
    module ? 62.0 kB ? (?)
  • @firebase/storage-compat

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 10.2 kB ? (?)
    main ? 28.1 kB ? (?)
    module ? 10.2 kB ? (?)
  • @firebase/storage-exp

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 50.5 kB ? (?)
    main ? 51.6 kB ? (?)
    module ? 50.5 kB ? (?)
  • @firebase/util

    Type Base (03e97b8) Head (94499b3) Diff
    browser ? 20.2 kB ? (?)
    esm2017 ? 19.0 kB ? (?)
    main ? 24.6 kB ? (?)
    module ? 20.2 kB ? (?)
  • @firebase/webchannel-wrapper

    Type Base (03e97b8) Head (94499b3) Diff
    esm2017 ? 39.5 kB ? (?)
    main ? 46.9 kB ? (?)
    module ? 40.8 kB ? (?)
  • firebase

    Click to show 15 binary size changes.
    Type Base (03e97b8) Head (94499b3) Diff
    firebase-analytics.js ? 35.8 kB ? (?)
    firebase-app.js ? 21.2 kB ? (?)
    firebase-auth.js ? 177 kB ? (?)
    firebase-database.js ? 183 kB ? (?)
    firebase-firestore.js ? 327 kB ? (?)
    firebase-firestore.memory.js ? 262 kB ? (?)
    firebase-functions.js ? 10.3 kB ? (?)
    firebase-installations.js ? 19.3 kB ? (?)
    firebase-messaging.js ? 41.0 kB ? (?)
    firebase-performance-standalone.es2017.js ? 72.9 kB ? (?)
    firebase-performance-standalone.js ? 49.2 kB ? (?)
    firebase-performance.js ? 38.3 kB ? (?)
    firebase-remote-config.js ? 36.9 kB ? (?)
    firebase-storage.js ? 40.8 kB ? (?)
    firebase.js ? 869 kB ? (?)

Test Logs


use(chaiAsPromised);

// TODO: Improve the coverage of these tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a bug number or a user name (e.g. wilhuff)

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.

Promise.reject(new FirestoreError(Code.ABORTED, 'zzyzx'));
const credentials = new MockCredentialsProvider();
const datastore = newDatastore(credentials, connection, serializer);
await expect(invokeDatastoreImplInvokeStreamingRPC(datastore))
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to verify that we return a FirestoreError. I think you can do this as such:

await expect(invokeDatastoreImplInvokeStreamingRPC(datastore)).to.be.eventually.rejectedWIth(new FirestoreError(Code.ABORTED, 'zzyzx'))

If that doesn't work, you can use a try/catch here.

This also applies to other tests such as"DatastoreImpl.invokeRPC() wraps unknown exceptions in a FirestoreError". Since GRPC errors also have codes, I suspect that these tests may have passed even without your change.

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. Unfortunately, the "nice" way of using rejectedWith as you suggest doesn't work. The check incorrectly fails with this message:

AssertionError: expected promise to be rejected with 'FirebaseError: [code=unknown]: zzyzx' but it was rejected with 'FirebaseError: [code=unknown]: zzyzx'

(note: both the actual and expected strings in the message are equal)

But I found that you can verify multiple properties at once. So I used that to verify that the name is FirebaseError in addition to verifying the code.

@schmidt-sebastian schmidt-sebastian removed their assignment Apr 16, 2021
@schmidt-sebastian schmidt-sebastian removed their assignment Apr 19, 2021
@dconeybe dconeybe merged commit 633463e into master Apr 19, 2021
@dconeybe dconeybe deleted the dconeybe/EnsureFirestoreErrorThrownInDatabaseTs branch April 19, 2021 15:19
@google-oss-bot google-oss-bot mentioned this pull request Apr 21, 2021
@firebase firebase locked and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UNKNOWN: 14 UNAVAILABLE: No connection established
3 participants