Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Multiple "concurrent" calls to init causing multiple fetches. #145

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

typotter
Copy link
Collaborator

@typotter typotter commented Jan 13, 2025


labels: mergeable

Fixes FF-3804

Motivation and Context

Eppo saw a dramatic increase in requests to the API and it was determined through investigation that multiple calls to init were being made before previous calls finished. Our code did not handle that case and would run the initialization workload (including fetching) for each init call until one of them resolved. This is bad because it causes additional network and CPU load for the client and increases the cost of delivery for Eppo.

Description

  • Map of API Key => Promise
  • init-wrapping method (init renamed to exclusiveInit and new method named init to preserve API).
  • check the map for a value at the start of init and delegate if one exists.
  • delete the value from the map when init completes - this indicates that the initialization workload is complete

How has this been tested?

  • new tests

src/index.spec.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@typotter typotter requested a review from felipecsl January 13, 2025 21:18
@typotter
Copy link
Collaborator Author

Thanks for the review, Felipe. ptal

Copy link
Member

@felipecsl felipecsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@typotter typotter merged commit 0e6b0d4 into main Jan 13, 2025
8 checks passed
@typotter typotter deleted the typo/fix/FF-3708-one-init branch January 13, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants