googleapis / googleapis/google-cloud-node

Firestore Repeatedly Returning Error: 5 NOT_FOUND

Open
#7,447 2 comments 1 reaction 1 assignee Claimed by @tom-andersen View on GitHub
api: firestore library: nodejs-firestore priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

I found support for this [issue](https://github.com/firebase/firebase-admin-node/issues/2563) from the firebase library but the issue exists in this library as well.

cloud.google.com/support told me this was "related to code and implementation" and "falls outside the scope of GCP tech support" even though I have the _Enhanced Support_ for $500 / mo.

The issue is that if you're not using a database with the default name you have to explicitly declare the databaseID when instantiating the `Firestore` object. [These docs](https://cloud.google.com/nodejs/docs/reference/firestore/latest/firestore/firestore#examples) never mention that or display an example of a database with a custom ID. The example given:

```js
const {Firestore} = require('@google-cloud/firestore');

// Create a new client
const firestore = new Firestore();

async function quickstart() {
// Obtain a document reference.
const document = firestore.doc('posts/intro-to-firestore');

// Enter new data into the document.
await document.set({
title: 'Welcome to Firestore',
body: 'Hello World',
});
console.log('Entered new data into the document');

// Update an existing document.
await document.update({
body: 'My first Firestore app',
});
console.log('Updated an existing document');

// Read the document.
const doc = await document.get();
console.log('Read the document');

// Delete the document.
await document.delete();
console.log('Deleted the document');
}
quickstart();
```

will fail unless the custom database ID is added explicitly as so:

```js
const firestore = new Firestore({
databaseId: 'custom-name'
});
```

it's probably best if you add the `projectId` there explicitly as well:

```js
const firestore = new Firestore({
projectId: 'my-project',
databaseId: 'custom-name'
});
```

The error message for trying to write to the database without an explicit ID is unhelpful:

```bash
Error: 5 NOT_FOUND:
at callErrorFromStatus (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
at Object.onReceiveStatus (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/client.js:193:76)
at Object.onReceiveStatus (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
at Object.onReceiveStatus (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
at ServiceClientImpl.makeUnaryRequest (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/client.js:161:32)
at ServiceClientImpl. (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:237:29
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
at repeat (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/normalCalls/retries.js:82:25)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/normalCalls/retries.js:125:13
at OngoingCallPromise.call (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/call.js:67:27)
at NormalApiCaller.call (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/google-gax/build/src/createApiCall.js:112:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Caused by: Error
at _firestore._traceUtil.startActiveSpan (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js:438:27)
at DisabledTraceUtil.startActiveSpan (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/telemetry/disabled-trace-util.js:16:16)
at WriteBatch.commit (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js:436:43)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/reference/document-reference.js:354:31
at DisabledTraceUtil.startActiveSpan (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/telemetry/disabled-trace-util.js:16:16)
at DocumentReference.set (/Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/firestore/build/src/reference/document-reference.js:346:43)
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/index.js:35:49
at /Users/billy/GitHub/trifle-labs/mmorps-gcp/functions/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:100:29
at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
code: 5,
details: '',
metadata: Metadata {
internalRepr: Map(1) { 'x-debug-tracking-id' => [Array] },
options: {}
},
note: 'Exception occurred in retry method that was not classified as transient'
}
```

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

1) Is this a client library issue or a product issue?
This is the client library for "@google-cloud/firestore" .

2) Did someone already solve this?

- [x] Search the issues already opened: https://github.com/googleapis/nodejs-firestore/issues
- [x] Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node
- Closest thing is [this](https://github.com/googleapis/google-cloud-node/issues/2086) which has a similarly unhelpful error message because the `projectId` was not set but no reference to `databaseId`.
- [x] Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js

3) Do you have a support contract?
- [x] Please create an issue in the [support console](https://cloud.google.com/support/) to ensure a timely response.

If the support paths suggested above still do not result in a resolution, please provide the following details.

#### Environment details

- OS: macOS 14.6.1 (23G93)
- Node.js version: v18.20.3
- npm version: 10.7.0
- `@google-cloud/firestore` version: 7.10.0

#### Steps to reproduce

1. Make your first database with a custom name.
2. write a doc to the collection as outlined above

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

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.