Skip to content

Make the UniFi request timeout configurable, default 90s - #462

Merged
drudge merged 2 commits into
mainfrom
unifi-request-timeout
Oct 19, 2026
Merged

drudge merged 2 commits into
mainfrom
unifi-request-timeout

Conversation

@drudge

@drudge drudge commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Requested by Nick

Before: every UniFi controller request had a fixed 30 second limit. On a busy console, listing reservations (rest/user, which returns every client the controller has ever seen) can take longer than that, so the homelab sync failed every cycle with context deadline exceeded (Client.Timeout exceeded while awaiting headers).

After: the limit defaults to 90 seconds and can be set with unifi.timeout (5s to 10m), or from a new optional Request Timeout field on the wizard's connection step.

How: unifi.Options gains Timeout, and zero falls back to unifi.DefaultRequestTimeout (90s). config.UniFi gains Timeout with omitempty and a RequestTimeout() helper, so an unset value is never written to the file. Validation rejects values outside 5s to 10m, and the wizard checks the field before it stores credentials. Both sync and preview pass the timeout through.

Upgrading

Nothing new is needed. A node from before this change can't read unifi.timeout, so in a cluster, upgrade every node before you set it. Until it's set, the key stays out of the replicated config.

Checks

  • go tool mage verify passes and gofmt -l . is clean
  • New tests cover the client default and override, config default, bounds, and encoding only when set, and the wizard carrying the value through to save and rejecting a bad one
  • Checked the new field in the Vandelay demo, desktop and phone, dark and light (below). No script errors or failed requests.

Screenshots

UniFi setup wizard, connection step (/integrations?setup=unifi), scrolled to the bottom. Before is main, after is this branch.

Before After
Desktop, dark
Desktop, light
Phone, dark
Phone, light

Listing every known client on a busy UniFi console can take longer than the
old fixed 30s limit, so syncs failed with context deadline exceeded. Add
unifi.timeout (5s to 10m, default 90s), a Request Timeout field in the
wizard's connection step, and docs. The key is only written when set so
older nodes can still read a replicated configuration.
@drudge drudge self-assigned this Oct 15, 2026
@drudge
drudge marked this pull request as ready for review October 19, 2026 22:44
drudge added a commit that referenced this pull request Oct 19, 2026

@drudge drudge left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review by Blake, posted by Whiteface: approve. Code complete, CI green.

The cluster upgrade-order constraint is real, not cautious: internal/config/config.go:675 uses decoder.DisallowUnknownFields(), so a 1.7.1 node receiving a replicated config with unifi.timeout rejects it. The 1.7.2 release notes must say: upgrade every node before setting unifi.timeout. Also note the new setting and the 30s → 90s default change.

Whiteface: both go into the 1.7.2-beta.1 notes (#467).

@drudge
drudge merged commit 89b30ca into main Oct 19, 2026
4 checks passed
@drudge drudge mentioned this pull request Oct 19, 2026
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