firebase / firebase/firebase-js-sdk

failed-precondition error not catchable

Open
#3,210 0 comments 0 reactions 0 assignees View on GitHub
api: firestore needs-attention question
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### [REQUIRED] Describe your environment

* Operating System version: macOS Catalina 10.15.4
* Browser version: 83.0.4103.61
* Firebase SDK version: 7.14.2 (via CDN)
* Firebase Product: firestore

### [REQUIRED] Describe the problem

If the Firestore database has not yet been created on a fresh Firebase project, attempting to call a method throws an internal error, and is not catchable on user land code.

#### Steps to reproduce:

1. Create a new Firebase project
2. Try to get some data from Firestore, catching a possible error
3. The error is shown on console, but not catchable.

#### Relevant Code:

```html

var firebaseConfig = {...};

firebase.initializeApp(firebaseConfig);

async function run() {
try {
await firebase.firestore().collection('foo').get();
} catch (e) {
// Error is swallowed and not thrown here...
console.log(e);
}
}

run();

```

This can come in handy when you're building something whereby users enter their own project details, but you want to check whether Firestore has been enabled on their project and show some sort of warning.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the provided HTML example, Firebase SDK 7.14.2, a fresh Firebase project, and Firestore left uncreated. Trace the failed-precondition error through the Firestore SDK and its promise handling; done means the rejected operation reaches the caller's catch block so user code can display a warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.