feat(netwatch): Add browser support for rough network changes (online/offline)#14
Merged
feat(netwatch): Add browser support for rough network changes (online/offline)#14
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/net-tools/pr/14/docs/iroh_gossip/ Last updated: 2025-03-04T09:32:15Z |
Merged
5 tasks
dignifiedquire
approved these changes
Mar 4, 2025
Contributor
dignifiedquire
left a comment
There was a problem hiding this comment.
a little note, otherwise lgtm
github-merge-queue bot
pushed a commit
to n0-computer/iroh
that referenced
this pull request
Mar 4, 2025
…ure in Wasm (#3206) ## Description - Enables the `netwatch` dependency in Wasm - Un-cfg-s the `netwatch::netmon::Monitor` in `magicsock::Actor` - Enables the `metrics` feature for Wasm by depending on a newer iroh-metrics - Minor: We go back to using `netwatch::ip::is_unicast_link_local`, as we can depend on that in Wasm again now. ## Notes & open questions There's some dependencies: - [x] Needs #3203 to be merged first - [x] Depends on n0-computer/net-tools#14 being merged - [x] And released - [x] Depends on a new release of the `iroh-metrics` main branch (I.e. n0-computer/iroh-metrics#11 being released) Closes #3195 ## Change checklist - [x] Self-review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Uses
window.navigator.onLineandwindow.addEventListener("online", ...)and friends to listen for network changes.Notes & open questions
I tested this manually in firefox, chromium and gnome's WebKit-based browser.
I'm not sure how easy it would be to set up automated testing for this :SPretty hard. I've at least made sure there's a node.js smoke test for this, so that using the API doesn't fail, even if the underlying
navigator.onLineor "online"/"offline" event listener APIs don't exist.Even if this were run in a browser, it'd be hard to trigger online/offline.
The code generally falls back to not doing monitoring when the platform doesn't support it (e.g. node.js). In that case, you just won't get any events.
Change checklist