Skip to content

Orbit file download stall timeout and 30s context timeout - #50984

Merged
MagnusHJensen merged 5 commits into
mainfrom
46801-context-timeout-stall-file-download
Aug 13, 2026
Merged

Orbit file download stall timeout and 30s context timeout#50984
MagnusHJensen merged 5 commits into
mainfrom
46801-context-timeout-stall-file-download

Conversation

@MagnusHJensen

@MagnusHJensen MagnusHJensen commented Aug 11, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #46801

The 30s context timeout can be tested with the package in the issue. The speculative software download stall timeout I was unable to repro with actual packages/files.

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

  • Timeouts are implemented and retries are limited to avoid infinite loops

  • If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features
    • File downloads now detect stalled transfers and stop after a configurable timeout.
    • Download progress continues to be reported while data is received.
    • Installer downloads enforce a 60-second no-progress timeout.
  • Bug Fixes
    • Requests that stop responding now time out after 30 seconds.
    • Response headers time out after 45 seconds.
    • Slow downloads that continue making progress can complete successfully.
  • Documentation
    • Added guidance on request and download timeout behavior.

Copilot AI lite review requested due to automatic review settings August 11, 2026 17:33
@MagnusHJensen
MagnusHJensen requested a review from a team as a code owner August 11, 2026 17:33
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 12e822b3-9cbf-429d-9280-d3e9b00938d1

📥 Commits

Reviewing files that changed from the base of the PR and between 9291250 and e68298b.

📒 Files selected for processing (1)
  • pkg/fleethttp/fleethttp.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/fleethttp/fleethttp.go

Walkthrough

The change adds configurable stall detection to FileResponse downloads. The watchdog tracks read progress, closes stalled response bodies, and returns context.DeadlineExceeded. Request handling now accepts caller-provided contexts and applies a 30-second timeout to non-BodyHandler responses. The HTTP transport applies a 45-second response-header timeout. Authenticated and external software-installer downloads use a 60-second no-progress timeout. Tests cover stalled, progressing, and disabled-watchdog downloads.

Possibly related PRs

  • fleetdm/fleet#50104: Translates installer download timeout and cancellation errors into user-facing messages.

Mergeability Score: ⚪ Minimal · up to e6829

The PR adds context-timeout and download-stall timeout handling with automated tests; no actionable merge-blocking risk remains, so it is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: an Orbit file download stall timeout and a 30-second context timeout.
Description check ✅ Passed The description includes the related issue, relevant checklist items, automated tests, and manual QA details; omitted sections are not applicable to this change.
Linked Issues check ✅ Passed The timeout and stall detection changes address issue #46801 by allowing stalled Setup Experience downloads to fail and retry after network disruption.
Out of Scope Changes check ✅ Passed The response timeout, stall detection, tests, changes file, and transport timeout all support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 46801-context-timeout-stall-file-download

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@client/orbit_client.go`:
- Line 527: Update both file-download request paths around
requestWithExternal/DoHTTPRequest to use a context with a bounded pre-body
deadline instead of context.Background(). Apply the deadline through
response-header/TLS setup while preserving the existing watchdog and allowing
the response body to download without that deadline limiting its duration.

In `@orbit/changes/46801-context-timeout-stall-file-download`:
- Line 1: Restrict the 30-second context timeout to authenticated non-file orbit
requests, and exclude file-download requests from that timeout path. Preserve
the existing stall watchdog as the timeout mechanism for file downloads.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b141b73e-cb28-4f91-97f8-5f9a32c41a9b

📥 Commits

Reviewing files that changed from the base of the PR and between a3fedd9 and 1aeb377.

📒 Files selected for processing (4)
  • client/base_client.go
  • client/base_client_stall_test.go
  • client/orbit_client.go
  • orbit/changes/46801-context-timeout-stall-file-download

Comment thread client/orbit_client.go
Comment thread orbit/changes/46801-context-timeout-stall-file-download

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds request/download timeouts in the Orbit client to prevent setup experience hangs caused by stalled network transfers (e.g., network filters) and to bound request latency.

Changes:

  • Introduces a per-download “stall timeout” watchdog that aborts downloads when no bytes are received for a configured duration.
  • Adds logic intended to apply a 30s context timeout to Orbit HTTP requests (with special handling for download paths).
  • Adds unit tests to validate stalled vs slow-but-progressing download behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
orbit/changes/46801-context-timeout-stall-file-download Documents the new 30s request timeout and 60s download stall timeout behavior.
client/orbit_client.go Threads request contexts and attempts to apply a 30s timeout while exempting download flows.
client/base_client.go Implements stall watchdog logic in FileResponse.Handle to abort stalled downloads.
client/base_client_stall_test.go Adds tests covering stalled download aborts and slow-progressing downloads completing successfully.
Suppressed comments (1)

client/orbit_client.go:770

  • authenticatedRequest currently special-cases *FileResponse, but other streaming/custom body handlers (e.g. *NullFileResponse used for alt=media downloads) will still get the 30s deadline and can be canceled even when they are slow-but-progressing. If request() is updated to enforce a 30s timeout by default, consider opting out for all BodyHandler responses by routing them through requestWithContext(context.Background(), ...) (no deadline) so streaming downloads rely on the stall watchdog instead of a fixed overall timeout.
	s := params.(fleet.SetOrbitNodeKeyer)
	s.SetOrbitNodeKey(nodeKey)

	if _, ok := resp.(*FileResponse); ok {
		// Handle file response here if needed
		err = oc.request(verb, path, params, resp)
	} else {
		// if not FileResponse, set context with timeout of 30 seconds for all other requests.
		ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
		defer cancel()
		err = oc.requestWithContext(ctx, verb, path, params, resp)
	}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/base_client.go
Comment thread client/orbit_client.go
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.63%. Comparing base (0b484b7) to head (e68298b).
⚠️ Report is 61 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #50984      +/-   ##
==========================================
+ Coverage   68.53%   68.63%   +0.09%     
==========================================
  Files        3980     3995      +15     
  Lines      256315   257583    +1268     
  Branches    13661    13661              
==========================================
+ Hits       175676   176794    +1118     
- Misses      65005    65060      +55     
- Partials    15634    15729      +95     
Flag Coverage Δ
backend 69.74% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread client/orbit_client.go
Comment thread client/base_client.go Outdated
Comment thread client/base_client.go Outdated
Comment thread client/orbit_client.go
cdcme
cdcme previously approved these changes Aug 12, 2026

@cdcme cdcme left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions, looks good overall.

@MagnusHJensen
MagnusHJensen requested a review from cdcme August 13, 2026 09:39
@MagnusHJensen

Copy link
Copy Markdown
Member Author

Thanks @cdcme I went through your comments and either made fixes or left a comment for you to look at

@MagnusHJensen
MagnusHJensen merged commit 0ed8144 into main Aug 13, 2026
53 checks passed
@MagnusHJensen
MagnusHJensen deleted the 46801-context-timeout-stall-file-download branch August 13, 2026 14:04
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.

Setup experience on macOS stalls when deploying an application with a network filter

3 participants