Skip to content

Close hub subscriptions that cannot catch up - #71

Merged
sduchesneau merged 1 commit into
developfrom
hub-subscriber-stall-timeout
Sep 23, 2026
Merged

sduchesneau merged 1 commit into
developfrom
hub-subscriber-stall-timeout

Conversation

@sduchesneau

Copy link
Copy Markdown
Contributor

Hub subscriptions were closed as soon as 100 blocks were waiting (SOURCE_CHAN_SIZE). On a chain producing ~14 blocks/s, a ~15s pause from the live source is followed by a burst of ~200 blocks arriving within milliseconds, faster than a consumer can send the first one, so every subscriber was dropped at once even though each would have drained the burst in under a second.

A subscription is now closed when:

  • its consumer has not emptied its waiting blocks for SubscriptionCatchUpTimeout (default 30s). This catches a consumer that is stuck or slower than the chain, whatever the block rate, and closes it with ErrSubscriptionBehind, which matches ErrSubscriptionChannelFull with errors.Is so substreams tier1 reconnects the same way.
  • SubscriptionMaxBufferedBlocks (default 10000) blocks are waiting, to bound memory. Queued blocks are the same pointers the hub broadcasts to every subscriber, so the worst case is about that many blocks in total, not per subscriber.

SOURCE_CHAN_SIZE is no longer read; firehose-core exposes both settings as flags.

Replace the 100-block SOURCE_CHAN_SIZE limit with a 10000-block cap and a 30s catch-up timeout, so bursts on fast chains no longer close healthy subscriptions.
@sduchesneau
sduchesneau merged commit 5a7b240 into develop Sep 23, 2026
3 checks passed
@sduchesneau
sduchesneau deleted the hub-subscriber-stall-timeout branch September 23, 2026 18:21
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