The title might be pretty vague, but I hope the repro will help to pinpoint the issue quickly.
Environment details
- OS: Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019
- Node.js version: v8.16.0, v10.16.0
- npm version: v6.4.1, v6.9.0
@google-cloud/firestore version: v2.0.0, v2.1.0
Steps to reproduce
Please run the following with version 2.0.0 or 2.1.0 of the library:
import { Firestore } from '@google-cloud/firestore';
import { credentials } from '@grpc/grpc-js';
const BATCH_SIZE = 16;
const firestore = new Firestore({
port: 8080,
projectId: 'test',
servicePath: 'localhost',
sslCreds: credentials.createInsecure(),
});
const collection = firestore.collection('collection');
const run = async () => {
const batch = firestore.batch();
for (let i = 0; i < BATCH_SIZE; ++i) {
batch.set(collection.doc(), {});
}
await batch.commit();
const snapshot = await collection.get();
console.log(snapshot.size);
};
run().catch(x => console.error(x.message));
An expected result would be to see BATCH_SIZE (16) in the console. In reality a random number is printed.
This code runs against Firestore Emulator, but I verified it against the Cloud environment too. To run it against the cloud environment, it should be sufficient to change instantiation of the client to:
const firestore = new Firestore({ projectId: 'my-project-id' });
I verified that it does work correctly on major version 1. You can use the following code (GRPC credentials must come from grpc library, not @grpc/grpc-js:
import { Firestore } from '@google-cloud/firestore';
import { credentials } from 'grpc';
const BATCH_SIZE = 16;
const firestore = new Firestore({
port: 8080,
projectId: 'test',
servicePath: 'localhost',
sslCreds: credentials.createInsecure(),
});
const collection = firestore.collection('collection');
const run = async () => {
const batch = firestore.batch();
for (let i = 0; i < BATCH_SIZE; ++i) {
batch.set(collection.doc(), {});
}
await batch.commit();
const snapshot = await collection.get();
console.log(snapshot.size);
};
run().catch(x => console.error(x.message));
The title might be pretty vague, but I hope the repro will help to pinpoint the issue quickly.
Environment details
@google-cloud/firestoreversion: v2.0.0, v2.1.0Steps to reproduce
Please run the following with version
2.0.0or2.1.0of the library:An expected result would be to see
BATCH_SIZE(16) in the console. In reality a random number is printed.This code runs against Firestore Emulator, but I verified it against the Cloud environment too. To run it against the cloud environment, it should be sufficient to change instantiation of the client to:
I verified that it does work correctly on major version
1. You can use the following code (GRPC credentials must come fromgrpclibrary, not@grpc/grpc-js: