firebase / firebase/firebase-admin-node

[FR] Custom default RetryConfig

オープン
#1,615 コメント 5 件 リアクション 2 件 担当者 1 名 @lahirumaramba が担当を希望しています GitHub で見る
api: core type: feature request
主要言語
TypeScript
スター
1.7k
フォーク
419
平均マージ
3日 10時間
マージ済み PR(30日)
16

説明

**Is your feature request related to a problem? Please describe.**
Please allow users of `firebase-admin-node` to define their own default `RetryConfig`

Currently, users are forced to use the [default `RetryConfig`](https://github.com/firebase/firebase-admin-node/blob/master/src/utils/api-request.ts#L202):

```js
export function defaultRetryConfig(): RetryConfig {
return {
maxRetries: 4,
statusCodes: [503],
ioErrorCodes: ['ECONNRESET', 'ETIMEDOUT'],
backOffFactor: 0.5,
maxDelayInMillis: 60 * 1000,
};
}
```

**Personal use case**: I have a Node app where I want **zero retries** for Firebase HTTP requests. Retries create `setTimeout` timers that can cause I/O polling blocking of `setImmediate` according to the [Event Loop](https://blog.insiderattack.net/handling-io-nodejs-event-loop-part-4-418062f917d1). Thus, retries are causing hitches (ranging from hundreds of milliseconds to a few seconds) in my otherwise tight `setImmediate` loop, which I want to run as interrupted as possible

---

**Describe the solution you'd like**
Please somehow allow users to define their own `RetryConfig`, perhaps as a parameter when initalizing Firebase Admin:
```js
import * as admin from 'firebase-admin';

const app = admin.initializeApp(
options?: admin.AppOptions | undefined, // perhaps include custom RetryConfig as a field in options?
// ...
)
```

---

**Describe alternatives you've considered**
1. Wrapping `firebase-admin-node` in a `Worker` and using `Comlink` to successfully prevent I/O polling blocking, but I'd rather avoid using `Worker`
2. Rewriting a barebones Node Firebase Admin with only the API endpoints I need, but I'd much rather use the official `firebase-admin-node`

---

**Additional context**
- https://github.com/firebase/firebase-admin-node/pull/518
- https://github.com/firebase/firebase-admin-node/pull/556

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。