Skip to content

Conversation

@rolodato
Copy link
Contributor

@rolodato rolodato commented Mar 20, 2025

This PR fixes #177, which is tested here: https://github.com/Flagsmith/flagsmith-nodejs-client/pull/178/files#diff-d51f632ca0e8d754d607e28740780bb82e314eb5b22dbba97edd8f2a7c7cb32cR344.

Breaking changes introduced in this PR:

  • this.environment is typed as not null, but this is not true. This should never have been exposed, and now we have a getEnvironment method that exposes a shared promise for the environment document
  • The environment argument for onEnvironmentChange handlers can now be undefined, which happens if there was an error. If we failed to update the environment, it doesn't make sense to send the previous environment as part of this event.
  • Flagsmith constructor now throws an error if local evaluation is enabled but a server-side key was not used. Previously it would log an error and continue

This PR also makes it so that the test suite does not cause actual API calls to Flagsmith. All HTTP calls in tests are now mocked.

Other misc fixes:

  • Setting environmentRefreshInterval: 0 prevents polling from starting
  • getIdentityFlags now actually uses a default flag handler if provided, or fails if it needs to be called but is missing. Previously this would fail and not use the default handler
  • Remove use of console.log and console.error, always use loggers

New features:

  • requestRetryDelayMilliseconds option to make retry delay configurable, previously hardcoded at 1 second. This, with the default 3x retries, made some tests take at least 3 seconds to finish. Now, we do 0 retries and 0 delay in tests by default.

@rolodato rolodato changed the title (WIP) fix!: Improve error handling when environment fetch fails. Minor type safety breaking changes fix!: Improve error handling when environment fetch fails. Minor type safety breaking changes Mar 20, 2025
@rolodato rolodato force-pushed the fix/initial-fetch branch from 88ab0ac to 88b9176 Compare March 21, 2025 13:29
@rolodato rolodato requested a review from khvn26 March 21, 2025 14:28
@rolodato rolodato requested a review from matthewelwell March 21, 2025 14:28
Co-authored-by: Matthew Elwell <[email protected]>
@rolodato rolodato merged commit b156a2e into main Mar 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants