Repository navigation
fix(mobile): probe network changes and refresh activity leases #5154
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
74f130d
fix(mobile): probe on network path changes, report leases on reconnect
t3dotgg a9a671e
test(connection): make reconnect hardening deterministic
juliusmarminge 1dd03a1
fix(mobile): preserve startup network path changes
juliusmarminge 1d5093b
fix(mobile): keep reconnect hardening scoped to client sessions
t3dotgg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
|
|
||
| import { | ||
| observeNetworkPath, | ||
| seedNetworkPathBaseline, | ||
| UNKNOWN_NETWORK_PATH, | ||
| } from "./network-path-change"; | ||
|
|
||
| describe("network path change detection", () => { | ||
| it("does not probe when the listener matches the seeded interface", () => { | ||
| const seeded = seedNetworkPathBaseline(UNKNOWN_NETWORK_PATH, "WIFI"); | ||
|
|
||
| expect(observeNetworkPath(seeded, "WIFI")).toEqual({ | ||
| baseline: { known: true, type: "WIFI" }, | ||
| shouldProbe: false, | ||
| }); | ||
| }); | ||
|
|
||
| it("probes when a known interface changes", () => { | ||
| const seeded = seedNetworkPathBaseline(UNKNOWN_NETWORK_PATH, "WIFI"); | ||
|
|
||
| expect(observeNetworkPath(seeded, "CELLULAR").shouldProbe).toBe(true); | ||
| }); | ||
|
|
||
| it("probes when the listener wins the race with the async seed", () => { | ||
| const observed = observeNetworkPath(UNKNOWN_NETWORK_PATH, "CELLULAR"); | ||
|
|
||
| expect(observed.shouldProbe).toBe(true); | ||
| expect(seedNetworkPathBaseline(observed.baseline, "WIFI")).toEqual({ | ||
| known: true, | ||
| type: "CELLULAR", | ||
| }); | ||
| }); | ||
|
|
||
| it("probes on the first known interface after an unknown observation", () => { | ||
| const seeded = seedNetworkPathBaseline(UNKNOWN_NETWORK_PATH, "WIFI"); | ||
| const unknown = observeNetworkPath(seeded, null); | ||
|
|
||
| expect(unknown.shouldProbe).toBe(false); | ||
| expect(observeNetworkPath(unknown.baseline, "CELLULAR").shouldProbe).toBe(true); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| export interface NetworkPathBaseline { | ||
| readonly known: boolean; | ||
| readonly type: string | null; | ||
| } | ||
|
|
||
| export const UNKNOWN_NETWORK_PATH: NetworkPathBaseline = { | ||
| known: false, | ||
| type: null, | ||
| }; | ||
|
|
||
| export function seedNetworkPathBaseline( | ||
| baseline: NetworkPathBaseline, | ||
| type: string | null, | ||
| ): NetworkPathBaseline { | ||
| if (baseline.known || type === null) { | ||
| return baseline; | ||
| } | ||
| return { known: true, type }; | ||
| } | ||
|
|
||
| export function observeNetworkPath( | ||
| baseline: NetworkPathBaseline, | ||
| type: string | null, | ||
| ): { | ||
| readonly baseline: NetworkPathBaseline; | ||
| readonly shouldProbe: boolean; | ||
| } { | ||
| if (type === null) { | ||
| return { | ||
| baseline: UNKNOWN_NETWORK_PATH, | ||
| shouldProbe: false, | ||
| }; | ||
| } | ||
| return { | ||
| baseline: { known: true, type }, | ||
| // If the initial async seed has not landed, the first listener event may | ||
| // itself be the WiFi/cellular transition. A cheap advisory probe is safer | ||
| // than losing that transition and waiting for the socket ping timeout. | ||
| shouldProbe: !baseline.known || baseline.type !== type, | ||
| }; | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.