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

Calling app.firestore().settings() from @firebase/testing breaks the app #3354

Closed
gustavopch opened this issue Jul 3, 2020 · 3 comments · Fixed by #3464
Closed

Calling app.firestore().settings() from @firebase/testing breaks the app #3354

gustavopch opened this issue Jul 3, 2020 · 3 comments · Fixed by #3464
Assignees

Comments

@gustavopch
Copy link

[REQUIRED] Describe your environment

  • Operating System version: Arch Linux 5.7.4-arch1-1
  • Browser version: Google Chrome Version 83.0.4103.116 (Official Build) (64-bit)
  • Firebase SDK version: 7.15.5
  • Firebase Product: firestore + testing

[REQUIRED] Describe the problem

Steps to reproduce:

Calling app.firestore().settings({ /* ... */ }) overrides the initial settings defined by @firebase/testing's initializeTestApp (as mentioned in this comment), so the tests stop working because it cannot connect to the local emulator anymore.

Logs
    [2020-07-03T16:30:02.104Z]  @firebase/firestore: Firestore (7.15.5): FirestoreClient Initializing. user= null

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.192Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: Get next mutation batch

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.193Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: Get next mutation batch

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.194Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: Locally write mutations

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.196Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: notifyLocalViewChanges

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.196Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: Get next mutation batch

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.196Z]  @firebase/firestore: Firestore (7.15.5): MemoryPersistence Starting transaction: Get next mutation batch

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.197Z]  @firebase/firestore: Firestore (7.15.5): Connection Creating Firestore stub.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.207Z]  @firebase/firestore: Firestore (7.15.5): Connection Opening GRPC stream

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:02.211Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream sending: { database: 'projects/test-1593793802077/databases/(default)' }

  console.warn node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.228Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream error. Code: 16 Message: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.230Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream ended.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.231Z]  @firebase/firestore: Firestore (7.15.5): PersistentStream close with error: FirebaseError: [code=unauthenticated]: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.235Z]  @firebase/firestore: Firestore (7.15.5): Connection Opening GRPC stream

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.235Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream sending: { database: 'projects/test-1593793802077/databases/(default)' }

  console.warn node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.380Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream error. Code: 16 Message: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.381Z]  @firebase/firestore: Firestore (7.15.5): Connection GRPC stream ended.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.381Z]  @firebase/firestore: Firestore (7.15.5): PersistentStream close with error: FirebaseError: [code=unauthenticated]: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

  console.log node_modules/@firebase/logger/dist/index.cjs.js:98
    [2020-07-03T16:30:03.381Z]  @firebase/firestore: Firestore (7.15.5): ExponentialBackoff Backing off for 361 ms (base delay: 1000 ms, delay with jitter: 508 ms, last attempt: 147 ms ago)

Relevant Code:

  const app = firebase.initializeTestApp({
    projectId,
    auth,
  })
 
+ app.firestore().settings({
+   ignoreUndefinedProperties: true,
+ })
@gustavopch
Copy link
Author

By the way, here's a workaround for anyone interested while this issue is not addressed:

app.firestore()._settings.ignoreUndefinedProperties = true

@thebrianchen thebrianchen self-assigned this Jul 7, 2020
@thebrianchen
Copy link

thebrianchen commented Jul 9, 2020

@gustavopch Thanks for reporting the issue and the workaround! The current behavior can definitely cause developer confusion because it's not straightforward to debug. We're currently thinking that we can either expose a getter for the settings object, or add an option to merge settings so that you don't have to use the workaround. I'm going to discuss with the team, and circle back to you soon.

@thebrianchen
Copy link

Just to circle back, we are planning to add a way to allow developers to merge their settings objects together when calling settings(), which should eliminate the need for such a hacky workaround. I'll update the issue when we get around to adding that feature.

This was referenced Aug 25, 2020
@firebase firebase locked and limited conversation to collaborators Sep 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants