Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Pass timeoutMs value in the request headers#4921

Merged
taras-yemets merged 3 commits into
mainfrom
ty/timeout-as-req-header
Jul 19, 2024
Merged

Pass timeoutMs value in the request headers#4921
taras-yemets merged 3 commits into
mainfrom
ty/timeout-as-req-header

Conversation

@taras-yemets

@taras-yemets taras-yemets commented Jul 18, 2024

Copy link
Copy Markdown
Contributor

Part of CODY-2775

Sends the timeoutMs config value to the backend using via X-Timeout-Ms header in both default and fast paths.

Backend support added in https://github.com/sourcegraph/sourcegraph/pull/63875

Test plan

Manually tested (using a debugger) alongside https://github.com/sourcegraph/sourcegraph/pull/63875 on both default and fast paths, using a locally running Sourcegraph instance and Cody Gateway.

@taras-yemets taras-yemets changed the title Pass timeoutMs value as request header Pass timeoutMs value in the request headers Jul 18, 2024
@taras-yemets taras-yemets requested review from a team and valerybugakov July 18, 2024 11:27
@taras-yemets taras-yemets merged commit 77b14f5 into main Jul 19, 2024
@taras-yemets taras-yemets deleted the ty/timeout-as-req-header branch July 19, 2024 14:06
taras-yemets referenced this pull request in sourcegraph/sourcegraph-public-snapshot Jul 19, 2024
Closes
[CODY-2775](https://linear.app/sourcegraph/issue/CODY-2775/%5Bautocomplete-latency%5D-apply-the-same-timeout-on-the-cody-gateway-side)



Enables client control over the request processing timeout on the server
(both Sourcegraph backend and Cody Gateway). The context timeout is set
to the value provided in the `X-Timeout-Ms` header of the client
request. If the header is not provided, the default context timeout is
used (1 minute on both Sourcegraph backend and Cody Gateway).

Previously, we only had a default timeout on the Sourcegraph backend
side (8 minutes).

Corresponding client change:
- https://github.com/sourcegraph/cody/pull/4921

<!-- 💡 To write a useful PR description, make sure that your description
covers:
- WHAT this PR is changing:
    - How was it PREVIOUSLY.
    - How it will be from NOW on.
- WHY this PR is needed.
- CONTEXT, i.e. to which initiative, project or RFC it belongs.

The structure of the description doesn't matter as much as covering
these points, so use
your best judgement based on your context.
Learn how to write good pull request description:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4
-->


## Test plan
- Manually tested and confirmed that if the request contains the
`X-Timeout-Ms` header, its value is used. If not, the default maximum
request duration is applied.
- CI
- 
<!-- All pull requests REQUIRE a test plan:
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->


## Changelog
- Use the provided timeout from request parameters if available;
otherwise use the default maximum request duration (8 minutes)

<!--
1. Ensure your pull request title is formatted as: $type($domain): $what
2. Add bullet list items for each additional detail you want to cover
(see example below)
3. You can edit this after the pull request was merged, as long as
release shipping it hasn't been promoted to the public.
4. For more information, please see this how-to
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c?

Audience: TS/CSE > Customers > Teammates (in that order).

Cheat sheet: $type = chore|fix|feat $domain:
source|search|ci|release|plg|cody|local|...
-->

<!--
Example:

Title: fix(search): parse quotes with the appropriate context
Changelog section:

## Changelog

- When a quote is used with regexp pattern type, then ...
- Refactored underlying code.
-->

@valerybugakov valerybugakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants