Skip to content

Make LimitStream stop sending results when the limit is hit

Warren Gifford requested to merge cc/limit-stream into main

Created by: camdencheek

Previously, when the limit was hit, we would cancel any jobs depending on the context returned when creating the LimitStream, but we would still send any events that those jobs sent after the context was cancelled. This meant that, even though we were "limiting" the stream, it was only a soft limit.

This makes it difficult to make guarantees for upstream consumers of a limited stream. For example, with AND searches, we want strictly no more than n results, but limit stream might return an unboundedly large number of results. This causes errors when I try to depend on LimitStream for AND searches.

Stacked on #30118

Merge request reports

Loading