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

Autocomplete: Implement client-side timeouts #1355

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

philipp-spiess
Copy link
Contributor

@philipp-spiess philipp-spiess commented Oct 10, 2023

This PR adds client side timeouts as discussed in this Slack thread.

The reason for this are the following:

Our current server-side backend does request retrying for a fixed number of times. For Autocomplete however, latency is of upmost importance so we don't really want to retry requests for a long time. In some cases, we see requests being retried for up to 30 minutes which is just putting additional pressure on the downstream processes without providing a great UX. Since timeouts are highly client specific, we decided that adding those to the client is the best approach for now. All of our middleware respect aborted requests so all we need to do is to start a race between a timeout and abort the request if that is hit.

Note: This PR is best reviewed with whitespace changes ignored.

Test plan

  • Modify the code to have a timeout below 100ms
  • Trigger an autocomplete request
  • Observe that a timeout error is thrown

@philipp-spiess philipp-spiess requested a review from a team October 10, 2023 15:52
@philipp-spiess philipp-spiess self-assigned this Oct 10, 2023
const abortController = signal ? forkSignal(signal) : new AbortController()
return Promise.race([
complete(params, onPartialResponse, abortController.signal),
createTimeout(params.timeoutMs).finally(() => {
Copy link
Member

Choose a reason for hiding this comment

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

can we make sure that these are not logged as errors in sentry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would we not want to log them in Sentry? The user is not getting a completion, seems like something we should have our eyes on to me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's a quota thing I think we should at least log this in our analytics somewhere.

Copy link
Member

Choose a reason for hiding this comment

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

If we expect this to be low volume that’s fine 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha yeah if this happens often we have to revisit this approach anyways 🫡

@philipp-spiess philipp-spiess merged commit aedc544 into main Oct 11, 2023
13 checks passed
@philipp-spiess philipp-spiess deleted the ps/ac-client-side-timeout branch October 11, 2023 09:33
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