Skip to content
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

feat: offline state recovery for Filter subscription #2049

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

weboko
Copy link
Collaborator

@weboko weboko commented Jun 27, 2024

Problem

In case light node goes offline some steps should be taken to recover as per RFC recommendation

Solution

Implement recovery by doing ping and re-subscription if needed.

Notes

  • Double check within dogfooding app
  • Add some tests

@weboko weboko marked this pull request as ready for review July 17, 2024 11:11
@weboko weboko requested a review from a team as a code owner July 17, 2024 11:11
@weboko weboko changed the title feat!: improve offline state handling for Filter subscription feat: improve offline state handling for Filter subscription Jul 17, 2024
@weboko weboko changed the title feat: improve offline state handling for Filter subscription feat: offline state recovery for Filter subscription Jul 17, 2024
Copy link

github-actions bot commented Jul 17, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 184.15 KB (+0.23% 🔺) 3.7 s (+0.23% 🔺) 16.1 s (-14.77% 🔽) 19.8 s
Waku Simple Light Node 184.16 KB (+0.14% 🔺) 3.7 s (+0.14% 🔺) 18.8 s (+63.87% 🔺) 22.5 s
ECIES encryption 23.12 KB (0%) 463 ms (0%) 5.8 s (+32.22% 🔺) 6.2 s
Symmetric encryption 22.58 KB (0%) 452 ms (0%) 4.8 s (-10.18% 🔽) 5.3 s
DNS discovery 72.49 KB (0%) 1.5 s (0%) 13.8 s (-2.39% 🔽) 15.2 s
Peer Exchange discovery 74.15 KB (0%) 1.5 s (0%) 15.7 s (+11.64% 🔺) 17.2 s
Local Peer Cache Discovery 67.68 KB (0%) 1.4 s (0%) 13.7 s (+24.85% 🔺) 15 s
Privacy preserving protocols 38.87 KB (0%) 778 ms (0%) 8.1 s (-4.62% 🔽) 8.9 s
Waku Filter 113.55 KB (+0.22% 🔺) 2.3 s (+0.22% 🔺) 13.4 s (-33.87% 🔽) 15.7 s
Waku LightPush 111.3 KB (0%) 2.3 s (0%) 15.9 s (+31.13% 🔺) 18.1 s
History retrieval protocols 111.78 KB (0%) 2.3 s (0%) 17 s (-20.81% 🔽) 19.2 s
Deterministic Message Hashing 7.29 KB (0%) 146 ms (0%) 1.7 s (-19.66% 🔽) 1.9 s

}
}
private isConnectedToNetwork: boolean = false;
private isConnectedToWakuNetwork: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

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

imo it's not immediately clear what being connected to network means vs being connected to waku network. might be worth adding a comment

private startBrowserNetworkStatusListener(): void {
try {
window.addEventListener("online", this.onEventHandlers["online"]);
window.addEventListener("offline", this.onEventHandlers["offline"]);
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about relying solely on window events to detect when there is an internet connection. Is it possible for the event listener to miss an online event? This could cause the app to be stuck in offline state when there is actually a connection present.

It might be worth manually checking the boolean value of navigator.onLine as a fallback when trying to take an action that depends on isConnectedToNetwork

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree. When we rely on these event listeners, we inherently rely on Libp2p's ability to be able to perform during these environmental changes that I'm not sure if reliable enough.
Relying on the client itself, ie, navigator sounds like a great way to do this, pending tests

Copy link
Collaborator

@danisharora099 danisharora099 left a comment

Choose a reason for hiding this comment

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

Can we introduce some tests that validate the diff for this? We can do this by mocking disconnection

}
this.contentTopics = contentTopics;
this.subscribeOptions = options;
this.startBackgroundProcess(options);
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's be verbose in what this backgroundProcess is, ie, keep alive pings

this.startNetworkMonitoring();
}

private stopBackgroundRoutine(): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Discrepancy in name: backgroundProcess and backgroundRoutine

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.

None yet

3 participants