Skip to content

feat(hosts): log slow host ops before they time out - #575

Merged
kahme247 merged 1 commit into
mainfrom
feat-slow-op-diagnostic-2026-11-23
Nov 23, 2026
Merged

kahme247 merged 1 commit into
mainfrom
feat-slow-op-diagnostic-2026-11-23

Conversation

@kahme247

@kahme247 kahme247 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Makes the next macOS host-op timeout diagnosable from the log alone.

#574's macOS Verify failed once with HostOpError: This machine did not answer validateCwd in time (lib/hosts/hub.ts:1090), and a second macOS failure's error text is not publicly readable. A local investigation could not reproduce the timeout — even the full suite under a 1-CPU constraint passed — and ruled out the obvious causes. The one thing the investigation kept hitting: a 30 s op timeout today leaves no trace of how slow the op was or where it stalled.

This adds a slow-op warning to the hub's request(): when a host op goes unanswered past linkTimings.slowOpWarnMs (10 s by default), it logs one console.warn naming the host label, the op, and the elapsed milliseconds, e.g. [omp-web] This machine has not answered validateCwd after 10000ms. The warning changes nothing about the op — no timeout, retry, or failure behaviour is touched, and ops whose deadline is shorter than the warning (e.g. the 5 s session search) never warn. The timer is cleared on settle, on failure, and on send failure, and is unref'd like the op deadline itself.

The threshold lives on the exported linkTimings object alongside opTimeoutMs, so tests shorten it the same way.

Verification

  • New tests in lib/hosts/hub.test.mjs: a slow op logs exactly one warning naming the host and op and then still times out with 504; an op answered before the threshold logs no warning. lib/hosts/hub.test.mjs: 95 pass / 0 fail, 3 runs.
  • Neighbours (session-index, link-protocol, link-integration, daemon-links, hub-v7, maintenance-hub): 183 pass / 0 fail.
  • npx tsc --noEmit clean; npx eslint clean on both touched files.

References #574 and #569.

Summary by CodeRabbit

  • Bug Fixes
    • Long-running host operations now generate a single warning after 10 seconds, while keeping their existing timeout and result behavior.
    • Operations completed before the warning threshold do not generate a warning.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The host hub now warns when an operation stays pending beyond a configured threshold. The warning does not change the operation’s timeout or outcome. Tests cover unanswered and timely answered operations.

Changes: Slow-operation warnings

Layer / File(s) Summary
Schedule and clear warning timers
lib/hosts/hub.ts, lib/hosts/hub.test.mjs
The host hub schedules a warning for pending operations whose timeout exceeds slowOpWarnMs. It clears the warning timer when the operation settles, fails, or cannot be sent. Tests verify a warning for an unanswered operation and no warning for a timely response.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: andrebrait

Merge Risk: Minimal · up to 664a0

This adds a warning log when a host operation is slow. Timeouts and results are unchanged, and no merge-blocking risk was found.

Security architecture risk: Low · up to 664a0

The warning improves timeout diagnosis without changing how host requests complete. Its main risk is to log integrity: a host name containing a line break can make one slow-operation warning look like multiple log entries, even if the operation later succeeds.

Retained concerns

  • Low · security · inferred: The new warning writes registry labels verbatim to server logs. A caller who can set a host label can store embedded line breaks, allowing an eligible slow operation to produce misleading log lines. Existing diagnostics already used raw labels, but the new path can emit before, and without, a request failure.
Security review details

Security Blast Radius

  • inferred — The supported impact is to the hub's server log and readers or collectors that interpret line breaks as record boundaries. Emission is bounded to one warning per eligible pending operation, not one warning per host. The warning does not include operation arguments, results, or credentials.

Security Findings and Attack Paths

  • inferred — A label supplied through host management is stored in the registry, captured when the hub issues an operation, and written verbatim if that operation remains pending past the threshold. Existing raw-label diagnostics predate the PR; this path adds emission on delay alone.

Trust Boundaries and Controls

  • observed — Host management remains under the existing web gate: it checks applicable API origins and requires a valid session or trusted proxy when a password is enabled. The separate daemon-link upgrade still checks its host token before opening a socket. The warning adds neither a route nor an authentication bypass.

Hardening Proposals

  • proposed — Escape line breaks and other control characters at the logging boundary, or use a structured logger that encodes labels as fields. This also protects against labels already stored in the registry.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: hosts now log a warning for slow operations before they time out. The raw summary and objectives both describe a slow-operation warning in lib/hosts/hub.ts that fires …
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.
Full details: Title check

Explanation

The title names the main change: hosts now log a warning for slow operations before they time out. The raw summary and objectives both describe a slow-operation warning in lib/hosts/hub.ts that fires at slowOpWarnMs (10 seconds) and leaves the timeout unchanged. The title uses the conventional feat(hosts) prefix and is specific enough for a teammate scanning history.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 186fe10b-9dc6-442b-aabb-6260dbc5831e
Commits

Reviewing files that changed from the base of the PR and between 67516fb and 664a063.

Files selected for processing: 2

  • lib/hosts/hub.test.mjs
  • lib/hosts/hub.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@kahme247
kahme247 merged commit 6885b39 into main Nov 23, 2026
5 checks passed
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