googleapis / googleapis/google-cloud-node

Expose and document the Firestore.projectId getter

Open
#7,443 1 comment 0 reactions 1 assignee Assigned to @wu-hui View on GitHub
api: firestore library: nodejs-firestore
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

### Please make sure you have searched for information in the following guides.

- [X] Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- [X] Check our Troubleshooting guide: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/troubleshooting
- [X] Check our FAQ: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/faq
- [X] Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- [X] Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- [X] Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples

### Documentation Request

Easy access to `db.projectId` would help diagnose [situations in which it's not clear that the correct project ID was picked up](https://stackoverflow.com/questions/79336721/where-does-firebase-admin-sdk-firestore-pick-up-its-project-id-from-if-not-sp).

```ts
import { initializeApp } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';

initializeApp();
const db = getFirestore();

// Running the run line below triggers "INTERNAL ERROR: Client is not yet ready to issue requests"
// console.log('Database project ID:', (db as unknown as { projectId: string})['projectId']);
```

It would also be useful to document *when* exactly the `projectId` becomes available (empirically after the first read operation).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.