question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore emulator does not support transactional queries

See original GitHub issue

[REQUIRED] Environment info

7.2.2

firebase-tools: 7.2.2

Platform: macOS 10.14.5

[REQUIRED] Test case

export const myFunction = functions.https.onCall(
    async (data: any, context: CallableContext): Promise<void> => {
        const db = admin.firestore();
        const my_collection: CollectionReference = db.collection(`test_collection`);
        return await db.runTransaction<void>(async (transaction) => {

            const result = await transaction.get(my_collection.doc());
            console.debug(result); // This works

            await transaction.get(my_collection.limit(1));
            // This will crash
        });
});

[REQUIRED] Steps to reproduce

Run firebase emulators:start and call the function from Web App

[REQUIRED] Expected behavior

Emulator should just work as production

[REQUIRED] Actual behavior

Unhandled error Error at Http2CallStream.<anonymous> (/PATH_TO_PROJECT/functions/node_modules/@grpc/grpc-js/build/src/call.js:68:41) at Http2CallStream.emit (events.js:208:15) at /PATH_TO_PROJECT/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:71:22 at processTicksAndRejections (internal/process/task_queues.js:75:11) { code: 2, details: ‘’, metadata: Metadata { options: undefined, internalRepr: Map { ‘content-type’ => [Array] } } }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanpbrewstercommented, Aug 9, 2019

Totally reasonable. There is a bit of work needed in order to support this without breaking the normal concurrency handling, but it’s very doable. I’ll keep this issue open to track the progress.

1reaction
ranmocycommented, Aug 8, 2019

That is a reasonable concern. If you ask me, I would say for an emulator, firstly it should allow any legitimate client code to run against it, and latter to behave as close to production version as possible. So I think it’s totally reasonable to minimize the support on concurrency cases.

That being said, would it be possible to have some simple implementation without support of concurrency first? That would allow us to write test for our Firebase functions which rely on Firestore heavily, where mocking Firestore doesn’t make a lot sense.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect your app to the Cloud Firestore Emulator - Firebase
Local Emulator Suite supports emulation of real Firebase projects and demo ... The emulator does not currently implement all transaction behavior seen in ......
Read more >
Datastore emulator returns 'Only ancestor queries are allowed ...
Datastore emulator returns 'Only ancestor queries are allowed inside transactions'. Doesn't it support Firestore in Datastore mode? Ask Question.
Read more >
Cloud Firestore | FlutterFire
Cloud Firestore does not support the following types of queries: Queries with range filters on different fields, as described in the previous section....
Read more >
Projects - OpenTeams, Inc.
Creating a ref does not involve any network traffic. ... This package supports the Cloud Firestore emulator, which is useful for testing and...
Read more >
Emulate Firestore locally | Google Cloud
Do not use the emulator for production deployments. Because the emulator stores data only in memory, it will not persist data across runs....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found