Skip to content

fix(subscriber): panic when reloading Filtered #3328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samugi
Copy link

@samugi samugi commented Jun 30, 2025

Motivation

Resolve #1629 without introducing a breaking change.

A workaround for this issue was introduced via filter_mut, which allows reloading the Filter of a Filtered layer — but it still doesn't support replacing the entire Filtered layer.

A breaking change was also proposed, but it comes with some downsides:

  • It cannot be included in a patch release.
  • As discussed in the Alternatives section here, it could introduce unintended side effects.

Solution

This change adds support for reloading filtered layers without breaking the existing API by introducing a dedicated Handle::reload_filtered method for reloading Filtered layers, and a Layer::on_reload_layer method for performing late initialization when a Layer is reloaded.

Handle::reload_filtered invokes the new Layer::on_reload_layer method on the layer. This method is responsible for registering the filter with the subscriber via register_filter_immut.

Unlike register_filter, the register_filter_immut function takes a shared reference to the subscriber, allowing filter registration after the subscriber has been fully initialized.

Usage examples for are included in the inline documentation.

Fixes: #1629

@samugi samugi requested review from hawkw and a team as code owners June 30, 2025 13:15
@samugi samugi force-pushed the fix/reload-filtered-layers branch from 3277c6e to cad5db4 Compare June 30, 2025 13:29
This commit adds support for reloading filtered layers without breaking
the existing API.

The `Reload` handle now provides a `reload_filtered` function, which
invokes a newly introduced `on_reload_layer` function on the `Layer`.
This function is responsible for registering the filter with the
subscriber via `register_filter_immut`.

Unlike `register_filter`, `register_filter_immut` takes a shared
reference to the subscriber, allowing the filter registration to occur
after the subscriber has been fully initialized.
@samugi samugi force-pushed the fix/reload-filtered-layers branch from cad5db4 to 6316fba Compare July 2, 2025 12:57
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.

Panic after reloading layer, combined with .with_filter
1 participant