Skip to content

Conversation

@anotherjesse
Copy link
Contributor

This PR addresses an issue where in-flight updates were still being delivered to a subscription even after it had been cancelled. This race condition caused the integrate() function to be called on a subscription whose controller had already been cleared, resulting in a fatal error.

To fix this, the integrate() function now checks if the subscription’s controller exists. If not, it logs a warning and simply ignores the update rather than throwing an error. Additionally, the subscription’s cancel() function ensures that all channels are unwatched and the subscriber is removed from active lists, preventing any future updates.

fixes #378

…subscriptions

Previously, integrate() would throw an error ("Subscription is cancelled")
if an update arrived after the subscription had been cancelled. This happened
due to a race condition where in-flight updates were still delivered even
after the subscription was removed from active subscriber lists.

Now, integrate() checks if the subscription’s controller is missing and
logs a warning while ignoring the update, rather than throwing an error.
This ensures that cancelled subscriptions do not cause fatal errors while
preventing memory leaks by properly unwatching and clearing subscriber channels.

fixes #378
Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Gozala Gozala merged commit 4d76e5b into main Feb 14, 2025
4 checks passed
@Gozala Gozala deleted the painful-integrations branch February 14, 2025 16:56
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.

crash due to subscription being canceled

3 participants