firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

[FR] Custom default RetryConfig

Open regnaio opened this issue 3 years ago • 4 comments

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:

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. 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:

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

regnaio avatar Mar 24 '22 10:03 regnaio

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Mar 24 '22 10:03 google-oss-bot

@lahirumaramba any updates on this? It is a much needed feature.

markusn avatar Feb 28 '23 14:02 markusn

@lahirumaramba I would like to retry when statusCodes includes 500 or 503. Is there any way to achieve that with current implementation or do we need to resolve @regnaio 's problem first?

dtsvn-minhnh avatar Mar 23 '23 09:03 dtsvn-minhnh

Related https://github.com/firebase/firebase-admin-node/issues/43#issuecomment-1619003500

Would be nice to have this.

treyshedrick avatar Jul 03 '23 19:07 treyshedrick