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

Optional request timeout #41

Merged
merged 5 commits into from
Nov 28, 2023
Merged

Conversation

aarsilv
Copy link
Contributor

@aarsilv aarsilv commented Nov 28, 2023

🎟️ Ticket: FF-1256 - Optionally pass and use, if present, the Sample Size Calculator Run ID in traffic count data tasks

Currently, our client has a hard-coded default timeout of five seconds (5000 milliseconds) to request the configuration from the CDN. If it fails, it will throw a timeout error.

image image image

However, some clients may want to specify the timeout. This pull request adds a new optional client configuration option, requestTimeoutMs, to allow upstream callers of init() to specify a desired timeout. If it's not specified, we continue to use our default.

This pull request also adds a helpful warning message explaining the impact of a failed initialization.

Lastly, some cleanup around package version compatibility and auto-generated docs have been done as well.

For example, the below results in an error when simulating six-second latency, but the error message shows the overridden three-second timeout is at play:

opts = {apiKey: '<API KEY>', requestTimeoutMs: 3000};
window.eppo.init(opts).then(function() {
  console.log('Client initialized');
});
image

And a timeout of ten seconds is sufficient for success even with six-second latency.

opts = {apiKey: '<API KEY>', requestTimeoutMs: 10000};
window.eppo.init(opts).then(function() {
  console.log('Client initialized');
});
image image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to be executable so it can run as a commit hook

@@ -4,7 +4,7 @@

## EppoJSClient.getAssignment() method

<b>Signature:</b>
**Signature:**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latest auto-generated docs use ** for bolding and _ for italic. (which I prefer in GitHub markdown anyways 📈 )


[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IClientConfig](./js-client-sdk.iclientconfig.md) &gt; [requestTimeoutMs](./js-client-sdk.iclientconfig.requesttimeoutms.md)

## IClientConfig.requestTimeoutMs property
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Autogenerated docs for newly added client configuration

@@ -49,7 +49,7 @@
"prettier": "^2.7.1",
"terser-webpack-plugin": "^5.3.3",
"testdouble": "^3.16.6",
"ts-jest": "^28.0.5",
"ts-jest": "^29.1.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

npm was not happy installing an older version of ts-jest with a newer version of jest. Bumping appeased it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did a yarn install using node 16.20, as that is the min version in our common client (source)

@aarsilv aarsilv marked this pull request as ready for review November 28, 2023 18:34
Copy link
Contributor

@sameerank sameerank left a comment

Choose a reason for hiding this comment

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

Maybe I missed it in the PR description: why was this needed for the sample size calculator? Were the counts looking wrong due to SDK timeouts?

try {
const axiosInstance = axios.create({
baseURL: config.baseUrl || constants.BASE_URL,
timeout: config.requestTimeoutMs || constants.REQUEST_TIMEOUT_MILLIS,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@aarsilv aarsilv merged commit f679c17 into main Nov 28, 2023
2 checks passed
@aarsilv aarsilv deleted the aaron/ff-1256/optional-request-timeout branch November 28, 2023 19:37
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.

3 participants