cachapa / firedart

A dart-native implementation of the Firebase Auth and Firestore SDKs
https://pub.dev/packages/firedart
Apache License 2.0
174 stars 62 forks source link

Document Stream does not work (at least on emulator) (gRPC INVALID_ARGUMENT) #121

Open penguisnt opened 1 year ago

penguisnt commented 1 year ago

flutter: gRPC Error (code: 3, codeName: INVALID_ARGUMENT, message: Database name "projects/XXX/databases/(default)/documents" has extra characters at index XX., details: [], rawResponse: null, trailers: {})

The issue is because the 'database' name is set with the trailing '/documents' suffix, which is invalid.

firestore_gateway.dart setListenRequest( does this:

            options: CallOptions(
                metadata: {'google-cloud-resource-prefix': database}))

The database here should be the database itself, not the 'collections' path (which is just a document in firestore). Passing the database name without the trailing '/documents' fixes the issue.

Firestore gateway likely should not set the 'database' equal to the data+'/documents' path, like it is doing here:

        database =
            'projects/$projectId/databases/${databaseId ?? '(default)'}/documents',
penguisnt commented 1 year ago

Here is the changes I made locally to fix the .stream issues, feel free to take as much of this as you want for yourself and merge it in, I unfortunately do not have the bandwidth for tests+pull request.

Note this also includes support for Firestore Auth emulator

https://github.com/penguisnt/firedart