Eppo-exp / node-server-sdk

Eppo Node.js SDK
MIT License
9 stars 0 forks source link

Non fatal polling and options for non-fatal startup #45

Closed aarsilv closed 8 months ago

aarsilv commented 8 months ago

🎟️ Ticket: FF-1426 - Node SDK - Non Fatal Polling

Motivation and Context

Presently, if polling for configuration hits an error (such as a timeout), polling will stop. However, some polling errors should be able to be tolerated to handle things like network or CDN hiccups.

Tip for Reviewers

Review this PR with the "Hide Whitespace" option:

image

Description

This PR adds two main things:

  1. Retries for the initial request of the configuration. These are separated by a short wait (~10% of the polling interval) as initialization is typically awaited so we don't want it to take too long.
  2. Retries for polling for updated configurations. These are separated by an exponential backoff, and if a certain amount fails, polling will stop.

It also adds the ability to have the initialization not throw an error on failure, and for it to attempt polling after a failed initial request. (E.g., initialize the server with no configurations, but leave the chance to get one later)

This is all controlled by newly added configuration options:

*Note that 7 retries means the last retry will be about 254 intervals after the failure. With our current interval of 30 seconds, this will be about two hours.

I also exposed requestTimeoutMs as an init() configuration option as it was already configurable downstream.

If we like these changes, I think we should move the poller to the common JS library and have these options for our client SDK as well, but perhaps with different defaults (e.g., throwOnFailedInitialization default to false).

How has this been tested?

Expansion of poller.spec and index.spec