firebase / firebase/firebase-admin-node

Top-level service accessors are broken (TypeError: this.ensureApp(...).auth is not a function)

Đang mở
#2,325 4 bình luận 6 reaction 0 người được giao Xem trên GitHub
api: core
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
16

Mô tả

### [READ] Step 1: Are you in the right place?

This is a bug report.

### [REQUIRED] Step 2: Describe your environment

* Operating System version: macOS Sonoma
* Firebase SDK version: 11.11.0
* Firebase Product: any
* Node.js version: 18.18.0

### [REQUIRED] Step 3: Describe the problem

The top-level service accessors (`auth()`, `firestore()`) provided by the `firebase-admin` don't work when provided an App object. However, the per-product accessors (`getAuth()`, `getFirestore()`) work fine.

Doesn't work:

```ts
import { auth, firestore } from "firebase-admin"
import { initializeApp } from "firebase-admin/app"

const firebase = initializeApp()
const authx = auth(firebase) // this fails
const firestorex = firestore(firebase) // also fails

// These do not fail when passed no args - they properly get the default app.
```

Full error when using accessors with an App instance looks like this:

```
/path/to/node_modules/firebase-admin/lib/app/firebase-namespace.js:136
return this.ensureApp(app).firestore();
^
TypeError: this.ensureApp(...).firestore is not a function
at fn (/path/to/scripts/node_modules/firebase-admin/lib/app/firebase-namespace.js:136:40)
at (/path/to/scripts/src/bootstrap_emulator.ts:8:20)
at Object. (path/to/scripts/src/bootstrap_emulator.ts:19:6)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Object.S (/path/to/scripts/node_modules/tsx/dist/cjs/index.cjs:1:1250)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at ModuleWrap. (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Node.js v18.18.0
```

However, these do work using per-product accessors:

```ts
import { initializeApp } from "firebase-admin/app"
import { getAuth } from "firebase-admin/auth"
import { getFirestore } from "firebase-admin/firestore"

const firebase = initializeApp()
const authx = getAuth(firebase)
const firestorex = getFirestore(firebase)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.