Fix/reliable channel and node cleanup #2717
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem / Description
The Waku SDK and core protocols lack proper cleanup mechanisms, leading to issues:
Solution
This PR tries to implement profound cleanup and resource management across all protocols and SDK layers.
Protocol Level Changes:
stop()methods to all protocols (Filter, LightPush, Store, Relay) to properly clean up stream managers and remove event listenersabortSignalparameter in the IStore interface, enabling graceful cancellation of long running queriesSDK Level Changes:
stop()to call protocol-level stop methods during shutdownstopAllRetries()method to cancel all pending retry operations and clear timeoutsstop()method that orchestrates cleanup of all child components, waits for pending tasks, unsubscribes from message streams, and removes all event listenersBreaking Changes:
The following methods are now async and must be awaited:
QueryOnConnect.stop()MissingMessageRetriever.stop()ReliableChannel.stop()Migration is straightforward - add
awaitwhen calling these methods.At SolarPunk, we are currently using ReliableChannels with all the changes on this branch.
We have not experienced the following errors since the changes:
I have not done anything regarding to testing. After review, if the changes are correct and acceptable, I'll do the required tests.
Checklist