Skip to content

throttle stream search events instead of debouncing

Administrator requested to merge master-dry-run/cc/throttle-not-debounce into main

Created by: camdencheek

This fixes an issue with our streaming search rendering pipeline that was, in some cases, causing no results to be rendered until the entire search was complete.

When reducing the stream of search events, we were rate-limiting the number of UI updates by piping them through debounceTime. The problem with debounceTime in this case is it will not emit an event until the configured time has passed and there have been no events observed. With streaming search though, we are sending a progress event every 100 milliseconds, so the condition to emit an update event was never met. In effect, this made it so no results were rendered on the page until the search was complete, after which 500 milliseconds would pass and the page would render.

This commit replaces debounceTime with throttleTime, which, instead of waiting for a period of no events, always emits an event after the interval if the value has changed. This change significantly improves the time to first rendered results.

Before:

https://user-images.githubusercontent.com/12631702/128783646-d8b855f3-83b5-4e74-b096-dab93b1ca54d.mov

After:

https://user-images.githubusercontent.com/12631702/128783642-9639cc34-31a6-42b5-9382-394d873a31fa.mov

Merge request reports

Loading