Repository navigation
iOS/Gateway: stabilize background wake and reconnect behavior - #21226
Merged
Merged
Conversation
Comment on lines
+346
to
+348
| private func beginBackgroundConnectionGracePeriod(seconds: TimeInterval = 25) { | ||
| self.grantBackgroundReconnectLease(seconds: seconds, reason: "scene_background_grace") | ||
| self.endBackgroundConnectionGracePeriod(reason: "restart") |
Contributor
There was a problem hiding this comment.
calling endBackgroundConnectionGracePeriod(reason: "restart") immediately after grantBackgroundReconnectLease could cause the lease to be granted but then the task cleanup to occur before the timer starts if there's already a task running - verify this ordering is intentional
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/ios/Sources/Model/NodeAppModel.swift
Line: 346-348
Comment:
calling `endBackgroundConnectionGracePeriod(reason: "restart")` immediately after `grantBackgroundReconnectLease` could cause the lease to be granted but then the task cleanup to occur before the timer starts if there's already a task running - verify this ordering is intentional
How can I resolve this? If you propose a fix, please make it concise.
Comment on lines
+136
to
+149
| if (!wakeResult.ok) { | ||
| return withDuration({ | ||
| available: true, | ||
| throttled: false, | ||
| path: "send-error", | ||
| apnsStatus: wakeResult.status, | ||
| apnsReason: wakeResult.reason, | ||
| }); | ||
| } | ||
| return withDuration({ | ||
| available: true, | ||
| throttled: false, | ||
| path: "sent", | ||
| apnsStatus: wakeResult.status, |
Contributor
There was a problem hiding this comment.
wrap this in try-catch to ensure withDuration helper is always called even if loadApnsRegistration or resolveApnsAuthConfigFromEnv throws unexpectedly - otherwise the returned attempt object won't have the durationMs field
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/server-methods/nodes.ts
Line: 136-149
Comment:
wrap this in try-catch to ensure `withDuration` helper is always called even if `loadApnsRegistration` or `resolveApnsAuthConfigFromEnv` throws unexpectedly - otherwise the returned attempt object won't have the `durationMs` field
How can I resolve this? If you propose a fix, please make it concise.
Contributor
Author
anisoptera
pushed a commit
to anisoptera/openclaw
that referenced
this pull request
Feb 20, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
mmyyfirstb
pushed a commit
to mmyyfirstb/openclaw
that referenced
this pull request
Feb 21, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
ogt-redknie
pushed a commit
to ogt-redknie/OPENX
that referenced
this pull request
May 2, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
This was referenced Jul 2, 2026
lhfer
pushed a commit
to lhfer/openclaw
that referenced
this pull request
Oct 11, 2026
…aw#21226) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7705a77 Co-authored-by: mbelinky <[email protected]> Co-authored-by: mbelinky <[email protected]> Reviewed-by: @mbelinky
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.
Summary
Describe the problem and fix in 2–5 bullets:
node.invoke.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
apps/ios/README.mdnow documents location-automation QA use case and pass criteria.Security Impact (required)
Yes/No): Yes (BG task identifier usage)Yes/No): NoYes/No): Yes (ping keepalive behavior)Yes/No): NoYes/No): NoYes, explain risk + mitigation:Repro + Verification
Environment
mb-serverSteps
nodes invoke device.status.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Compatibility / Migration
Yes/No): YesYes/No): No (uses existing APNs env if present)Yes/No): NoFailure Recovery (if this breaks)
apps/ios/Sources/Model/NodeAppModel.swift,apps/ios/Sources/OpenClawApp.swift, andsrc/gateway/server-methods/nodes.ts.Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.NODE_WAKE_THROTTLE_MS,NODE_WAKE_NUDGE_THROTTLE_MS) and best-effort behavior.Greptile Summary
This PR stabilizes iOS background wake behavior by introducing controlled reconnect suppression with lease-based windows, APNs wake retry logic with user nudges, and websocket ping-based keepalive.
The changes successfully address the problem of iOS reconnect churn in the background by implementing an explicit idle mode after a 25-second grace period. Wake paths are now more robust with retry logic and better instrumentation on both iOS and gateway sides.
Key improvements:
healthcalls to lightweight ping framesThe implementation includes proper throttling (15s for wake attempts, 10min for user nudges, 3min for location wakes), graceful cleanup with weak references, and updated test coverage for the retry behavior.
Confidence Score: 4/5
NodeAppModel.swiftandnodes.tsin production for wake behavior - check logs for excessive nudges or missed wakesLast reviewed commit: 667772b