firebase / firebase/firebase-admin-node

Database connectivity errors are not propagated

Aperta
#2,004 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
api: database
Lingua principale
TypeScript
Stelle
1.7k
Fork
419
Merge medio
3g 10h
PR unite (30g)
16

Descrizione

### Step 2: Describe your environment

* Operating System version: all
* Firebase SDK version: 10+
* Firebase Product: database
* Node.js version: all
* NPM version: all

### Step 3: Describe the problem

Errors in connecting to the database are not propagated to user's code. Instead, the library will wait indefinitely when an attempt is made to read or write to the database.

#### Steps to reproduce:

Provide either:
* valid credentials that do not have correct scopes or permissions to access the database
* invalid database url

App initialization will succeed.

Attempt to read or write to the database, triggering an attempt to connect to the database.

Errors will be written to the console, but the error handlers (either the callback on set() or promise rejections) will not be called.

Example error in logs:
```
@firebase/database: FIREBASE WARNING: Firebase error. Please ensure that you have the URL of your Firebase Realtime Database instance configured correctly.
```

Note that this is appears to be a change going from v9 to v10 of the firebase-admin library.

#### Relevant Code:

```
const firebase = require('firebase-admin');

const app = firebase.initializeApp({
credential: credentialWithoutPermissions, // only one of these mistakes is required.
databaseURL: wrongDatabaseUrl,
});

const db = firebase.database();

db.ref('foo').get().then(
() => {
// won't be called because it won't succeed
},
err => {
// won't be called because the failure doesn't propagate
});
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reproducing the failure with the provided firebase-admin initialization and database read example, using an invalid database URL or insufficient permissions. Compare the behavior between SDK versions 9 and 10, then trace database connection failures through the read/write error handling. Done means callbacks receive the error and promise-based operations reject instead of waiting indefinitely.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js, typescript
Ambito
databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.