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

Document references from another DB cause error logs #8166

Open
tzappia opened this issue Apr 15, 2024 · 2 comments
Open

Document references from another DB cause error logs #8166

tzappia opened this issue Apr 15, 2024 · 2 comments

Comments

@tzappia
Copy link

tzappia commented Apr 15, 2024

Operating System

macOS 14.4.1

Browser Version

Chrome/123.0.6312.124

Firebase SDK Version

10.11.0

Firebase SDK Product:

Firestore

Describe your project's tooling

Angular 17 app

Describe the problem

When using imported production data in a dev environment with an app using the Firebase emulators, I get the following error in the browser JavaScript console:

@firebase/firestore: Firestore (10.11.0): Document users/<documentId> contains a document reference within a different database (<databaseName>/(default)) which is not supported. It will be treated as a reference in the current database (demo-project/(default)) instead.

This appears to have no functional impact (I looked at the source Firebase code and the only action taken for this reference check is to log an error.) When loading a page with a long list of documents, this causes my Chrome JavaScript console to grind to a halt and become pretty unresponsive (there are many, many instances of this error log.)

Since this is more informational than an actual error, ideally this log would just be removed and be covered in documentation if necessary. In addition, if there are any tips for importing production data an an emulated environment and having all document references converted appropriately, I'd be happy to learn about it!

There is a comment in the code where the error is logged // TODO(b/64130202): Somehow support foreign references. but this bug report is about the error log and not asking for support for foreign references.

Steps and code to reproduce issue

  1. Export Firestore data from a production database.
  2. Import that data when launching an app that uses the emulators with the --import flag.
  3. In the development environment app that uses the emulator, query documents that include a Reference in the document data.
@tzappia tzappia added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Apr 15, 2024
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Apr 15, 2024
@dconeybe dconeybe self-assigned this Apr 19, 2024
@dconeybe
Copy link
Contributor

Hi @tzappia. Thank you for reporting this issue. I'm able to reproduce it and I can see how it would be a nuisance.

Here are the steps that I followed:

  1. Extract firestore_export_data.zip to a directory on your local computer.
  2. Start the Firestore emulator: firebase emulators:start --only firestore --import 2024-04-19T16:22:17_20757 (the path to --import is the directory that was created upon extracting the zip file).
  3. Run a query in the collection EmulatorImportIssue8166.

Expected Results:
No warnings are logged.

Actual Results:
The following warning is logged to the console: Document EmulatorImportIssue8166/DocA contains a document reference within a different database (dconeybe-testing/(default)) which is not supported. It will be treated as a reference in the current database (foo-bar-baz/(default)) instead.

Here is some sample code to run the query:

const db = getFirestore();
const collectionRef = collection(db, "EmulatorImportIssue8166");
const snapshot = await getDocs(collectionRef);
for (const documentSnapshot of snapshot.docs) {
  console.log(`Document: ${documentSnapshot.id}: ${JSON.stringify(documentSnapshot.data())}`);
}

Attachments:

@dconeybe
Copy link
Contributor

I've logged b/335854401 to track this request internally. Note, however, that I can't make any promises as to if or when we will fix this. But we will reply back if there is any progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants