Skip to content

Extend write deadline for app install/uninstall RPCs - #304

Open
mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:fix/install-uninstall-write-deadline
Open

Extend write deadline for app install/uninstall RPCs#304
mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:fix/install-uninstall-write-deadline

Conversation

@mobile-kevin

@mobile-kevin mobile-kevin commented Jul 17, 2026

Copy link
Copy Markdown

Summary

device.apps.install (and device.apps.uninstall) run under the HTTP server's default 10s WriteTimeout because they were never added to the per-method write-deadline extension in handleJSONRPC. On devices where an install legitimately takes longer than 10s, the server hits the write deadline and closes the connection mid-response. The caller — mobilefleet-client — sees an opaque:

mobilecli call failed: Post "http://localhost:12000/rpc": EOF

…and reports the install as failed, even when the app is valid (it installs fine from the web portal). Because the error is a bare transport EOF, it reads like a bad app rather than a timeout, which is exactly how it was mis-triaged.

Evidence

From production logs, install outcomes over 2 days:

Outcome Attempts avg min max
success 30 4.9s 0s 10s
fail (EOF) 11 19.9s 11s 68s

A clean split at the 10s boundary: every success finished ≤10s, every EOF failure took ≥11s — the signature of the WriteTimeout firing. The mobilecli process stays alive throughout (its heartbeat RPCs keep succeeding), so it isn't a crash; only the long install request is severed. mobilefleet-client's own RPC client timeout is 5 minutes, so it is not the limiter.

Fix

device.boot already extends the write deadline to 3 minutes for exactly this reason; install/uninstall are just as slow and were simply missing from the list. This adds them, and refactors the per-method deadlines into a small, testable extendedWriteDeadline() helper so a slow method can't be silently omitted again.

Testing

  • go test ./server/ — full package green, including two new tests (TestExtendedWriteDeadlineForSlowMethods, TestNoExtendedWriteDeadlineForFastMethods).
  • go vet ./server/, gofmt clean.

Notes / scope

  • This stops installs from being killed at 10s. It does not make genuinely slow installs faster — if some devices take 60s+, that's a separate device-provisioning question worth its own look.
  • The truly robust design is async install + poll rather than one long synchronous request, but that's a larger change across mobilecli and mobilefleet-client and isn't needed to stop the failures now.
  • A complementary mobilefleet-client change (classify the transport EOF distinctly from a real install rejection so it isn't reported as a generic "Install failed") is worth doing separately.

https://claude.ai/code/session_01NTmaydwxEmvPEYdiK3Q4yS

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ca3ecf61-b850-43a1-8aa3-ccbd97cba9d8

📥 Commits

Reviewing files that changed from the base of the PR and between 9b99c19 and 3a1f211.

📒 Files selected for processing (2)
  • server/deadline_test.go
  • server/server.go

Walkthrough

The server adds an extendedWriteDeadline helper that returns method-specific durations for long-running JSON-RPC methods. handleJSONRPC uses the helper to conditionally extend the HTTP response write deadline. Unit tests cover expected three-minute and 35-second extensions, plus fast and empty method names that receive no extension.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: extending write deadlines for app install/uninstall RPCs.
Description check ✅ Passed The description is directly related to the change and explains the deadline extension, refactor, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

device.apps.install and device.apps.uninstall run under the default 10s
WriteTimeout because they were missing from the per-method deadline
extension in handleJSONRPC. On devices where an install takes longer
than 10s, the server hits the write deadline and closes the connection
mid-response; the caller (mobilefleet-client) sees an opaque
`Post "http://localhost:12000/rpc": EOF` and reports the install as
failed even though the app is valid.

Extend the deadline to 3 minutes for install/uninstall (matching
device.boot) and refactor the per-method deadlines into a testable
extendedWriteDeadline() helper with unit tests, so a slow method can't
be silently omitted from the list again.

Claude-Session: https://claude.ai/code/session_01NTmaydwxEmvPEYdiK3Q4yS
@mobile-kevin
mobile-kevin force-pushed the fix/install-uninstall-write-deadline branch from fc435a0 to 3a1f211 Compare July 17, 2026 19:40
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.

1 participant