firebase-admin-node
firebase-admin-node copied to clipboard
[Firestore] random number of records are fetched in bun runtime
Runtime environment
- Operating System version: Ubuntu 22.04.4 LTS
- Firebase SDK version: 12.2.0
- Firebase Product: Firestore
- Node.js version: Bun v1.1.13
- NPM version: N/A
Note
Not sure this is an issue from the @google-cloud/firestore
This bug will NOT reproduce at NodeJS environment. (Tested v16 and v21)
Bug Description
No error, no warnings; It returns random number of records. Total user record count is about 200.
Source code
import { initializeApp, applicationDefault, cert } from "firebase-admin/app";
import { getFirestore, Timestamp } from "firebase-admin/firestore";
import type { Query } from "firebase-admin/firestore";
const credential = applicationDefault();
const firebaseApp = initializeApp({ credential });
const db = getFirestore(firebaseApp);
let query: Query = db.collection("users");
query = query.orderBy("createdAt", "desc").limit(100);
// [BUG] It returns random number of records
const documentSnapshot = await query.get();
This bug will occur without orderBy and limit. It returns the same(=random) result with this.
await db.collection('users').get()
package.json
package.json(partial)
"type": "module",
"dependencies": {
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.19.2",
"firebase-admin": "^12.2.0",
"morgan": "^1.10.0"
},
"devDependencies": {
"@types/bun": "latest",
"@types/cors": "^2.8.17",
"@types/morgan": "^1.9.9"
},
"peerDependencies": {
"typescript": "^5.5.3"
}
Firestore table schema
export interface UserRecord {
id: string;
displayName: string;
email: string;
createdAt: Date;
company: string;
title: string;
phone: string;
interest: string;
acl: string[];
}
No combined index defined.