Skip to content

fix: Circuit-breaker for Code Suggestions (Web IDE)

Enrique Alcántara requested to merge 412326-circuit-breaker-code-suggestions into main

When receiving sequential error responses from the code suggestions API, lower the frequency of API requests while user types. After 4 sequential error responses, the code completions provider will only send a fetch completions HTTP request every 10 seconds. Every subsequent HTTP request will double the waiting time before another request is fired.

How does it work?

A CircuitBreaker class tracks the number of HTTP request failures. When it counts 4 subsequent requests, it marks itself as "breaking" and it unmarks itself after X ms. GitLabCodeCompletionProvider uses this state to decide if it should continue sending API requests or not.

How to test in your local environment

Related gitlab#412326 (closed)

Edited by Enrique Alcántara

Merge request reports