fix(connection): refresh network status after app activation #5597
ClosedDominicVonk(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/5597/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
DominicVonk(GitHub profile, opens in a new tab) changed the title
- packages/client-runtime/src/connection/connectivity.ts line 74Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -19,0 +48,21 @@48+ yield* options.apply(status);49+ }50+ });51+52+ const refreshCurrentStatus = Effect.gen(function* () {53+ const startedAt = yield* Ref.get(reportCount);54+ const status = yield* connectivity.status;55+ yield* applyLock.withPermits(1)(56+ Effect.gen(function* () {57+ if ((yield* Ref.get(reportCount)) === startedAt) {58+ yield* applyStatus(status);59+ }60+ }),61+ );62+ });63+64+ yield* connectivity.changes.pipe(65+ Stream.runForEach((status) =>66+ applyLock.withPermits(1)(67+ Ref.update(reportCount, (count) => count + 1).pipe(Effect.andThen(applyStatus(status))),68+ ),
- packages/client-runtime/src/connection/connectivity.ts line 66Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -19,0 +45,21 @@45+ : ([true, Option.some(status)] as const),46+ );47+ if (changed) {48+ yield* options.apply(status);49+ }50+ return changed;51+ });52+53+ const refreshCurrentStatus = Effect.gen(function* () {54+ const startedAt = yield* Ref.get(reportCount);55+ const status = yield* connectivity.status;56+ yield* applyLock.withPermits(1)(57+ Effect.gen(function* () {58+ if ((yield* Ref.get(reportCount)) === startedAt) {59+ yield* applyStatus(status);60+ }61+ }),62+ );63+ });64+65+ yield* connectivity.changes.pipe(
- packages/client-runtime/src/connection/connectivity.ts line 66Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -19,0 +44,21 @@44+ ? ([false, current] as const)45+ : ([true, Option.some(status)] as const),46+ );47+ if (changed) {48+ yield* options.apply(status);49+ }50+ });51+52+ const refreshCurrentStatus = Effect.gen(function* () {53+ const startedAt = yield* Ref.updateAndGet(revision, (current) => current + 1);54+ const status = yield* connectivity.status;55+ yield* applyLock.withPermits(1)(56+ Effect.gen(function* () {57+ if ((yield* Ref.get(revision)) === startedAt) {58+ yield* applyStatus(status);59+ }60+ }),61+ );62+ });63+64+ yield* connectivity.changes.pipe(
- packages/client-runtime/src/relay/discovery.ts line 328OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -315,12 +314,15 @@314+ apply: (networkStatus) =>315315 networkStatus === "offline"316316 ? SubscriptionRef.update(state, (current) => ({317317 ...current,318318 refreshing: false,319319 offline: true,320320 }))321- : Ref.get(hasRefreshed).pipe(322- Effect.flatMap((shouldRefresh) => (shouldRefresh ? refresh : Effect.void)),323- ),324- ),325- Effect.forkScoped,326- );321+ : Effect.gen(function* () {322+ yield* SubscriptionRef.update(state, (current) => ({323+ ...current,324+ offline: false,325+ }));326+ if (yield* Ref.get(hasRefreshed)) {327+ yield* refresh.pipe(Effect.forkIn(scope));328+ }
- packages/client-runtime/src/connection/supervisor.ts line 756Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -755,15 +755,4 @@755755 }756756 });757757758- yield* connectivity.changes.pipe(759- Stream.runForEach((network) =>760- Ref.modify(intent, (current) =>761- current.network === network ? [false, current] : ([true, { ...current, network }] as const),762- ).pipe(763- Effect.flatMap((changed) =>764- changed ? signal({ _tag: "NetworkChanged", network }) : Effect.void,765- ),766- ),767- ),768- Effect.forkScoped,769- );758+ const applyNetworkStatus = Effect.fnUntraced(function* (network: NetworkStatus) {
DominicVonk(GitHub profile, opens in a new tab) changed the title
DominicVonk(GitHub profile, opens in a new tab) changed the title
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
deaa0201-97bc-486d-a84f-5edd5b49dafbYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share