Skip to content

fix(usage): stop Keychain probes after a timeout - #760

Merged
sirmalloc merged 2 commits into
sirmalloc:mainfrom
IndelibleVivi:fix/keychain-timeout-stop
Oct 29, 2026
Merged

sirmalloc merged 2 commits into
sirmalloc:mainfrom
IndelibleVivi:fix/keychain-timeout-stop

Conversation

@IndelibleVivi

Copy link
Copy Markdown
Contributor

A macOS Keychain lookup that reaches its five-second subprocess timeout currently falls through like an ordinary miss. The default-service lookup can then run dump-keychain, and a timed-out candidate can be followed by more candidate reads, adding work while the Keychain is already unresponsive.

Distinguish explicit subprocess timeouts using the structured ETIMEDOUT code. Stop further Keychain probes for that lookup and proceed to the current profile's credentials file. Ordinary misses still use the existing fallback chain. Profile isolation, credential identity checks before cache reads, and the 30-second no-credentials backoff remain unchanged.

Related to #740. This addresses the within-call timeout cascade; it does not address per-render successful reads, longer failure backoff, or the broader securityd problem.

Validation on macOS with Bun 1.4.2:

  • Against upstream 59ada51, both new unit regressions fail and the real-timeout integration test records an unwanted dump-keychain call.
  • The integration test runs a harmless fake security that reaches the real five-second timeout, asserts termination and a single Keychain call, and confirms credentials-file fallback. It runs only on macOS.
  • Unit coverage includes candidate timeout, custom-profile timeout isolation, ordinary miss fallback, and Linux/Windows file-only branches. Existing account-cache and cross-process backoff tests pass.
  • bun test src/utils/__tests__/usage-token.test.ts src/utils/__tests__/usage-fetch.test.ts: 88 passed, 0 failed.
  • bun test: 3254 passed, 0 failed across 180 files.
  • bun run lint, bun run build, and git diff --check: passed.
  • Harmless child-process probes under Node 26.7.0 and Bun 1.4.2 both report ETIMEDOUT with SIGTERM; timeout detection does not match error-message text.

No real Keychain or live usage API was used for validation. Native Linux/Windows execution, Node 14 execution, and reproduction of the original securityd failure were not performed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T04:53:44.378115Z
We couldn’t complete this review. Comment @codex review to try again.
cc3fb55 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sirmalloc
sirmalloc merged commit 7cabd22 into sirmalloc:main Oct 29, 2026
3 checks passed
pcvelz added a commit to pcvelz/ccstatusline-usage that referenced this pull request Oct 29, 2026
Upstream: Extra Usage Limit widget (sirmalloc#756), live widget preview while picking (sirmalloc#755), Fast Mode widget (sirmalloc#754), transcript block fallback fixes (sirmalloc#752), editor keys on a global install (sirmalloc#751), git cache TTL (sirmalloc#750), npx cached copy skip (sirmalloc#749), Block Usage hide at 100% (sirmalloc#747), Block Reset Timer hide until 100% (sirmalloc#697), fish-style branch abbreviation (sirmalloc#614), jj detached HEAD (sirmalloc#705), hooks save warning (sirmalloc#703), dev reload (sirmalloc#700), merge ends at a hidden widget (sirmalloc#698), Block Forecast and Block Limit Timer widgets (sirmalloc#699), contributor guide (sirmalloc#706), POSIX path case fix (sirmalloc#707), whitespace-distinct conflict filenames (sirmalloc#709), Quick Start reorder (sirmalloc#715), bunx launch guidance (sirmalloc#714), jj diff summary counts (sirmalloc#711), powerline manual separators (sirmalloc#713), keychain credential by account (sirmalloc#532), Keychain probe timeout (sirmalloc#760), usage cache scoped per CLAUDE_CONFIG_DIR (sirmalloc#266), test isolation (sirmalloc#717, sirmalloc#753), dev-dependency bumps (sirmalloc#745)

Conflicts resolved per the standard-resolution table; fork deletions re-applied.

Hand edits outside conflicts:
- src/utils/global-command-resolution.ts: fork-rename (ccstatusline@ -> ccstatusline-usage@ in upstream's new bunx pattern)
- src/utils/__tests__/global-package-manager.test.ts: fork-rename (package dir ccstatusline-usage in upstream's new tests)
- src/utils/usage-fetch.ts: compat fix - cacheUsageData gained a fetchedAtMs arg (upstream sirmalloc#266); adapted the fork-only fetchFreshUsageData call site
- src/utils/__tests__/usage-fetch.test.ts: compat fixes - cache/lock now hashed per CLAUDE_CONFIG_DIR (usageFilePath helper) in four fork tests; upstream fableUsage renamed to fork's weeklyFableUsage; seedUsageCache takes TokenHome
- src/utils/__tests__/usage-prefetch.test.ts: compat fix - mockFetchUsageData renamed to upstream's mockFetchUsage in cleanly-merged tests
- README.md: took upstream's Quick Start move (sirmalloc#715) and dropped the fork's old copy; fork-rename of its ccstatusline@ specifiers; links to fork-deleted docs (docs/USAGE.md, docs/WINDOWS.md) replaced with the fork's inline text
- CONTRIBUTING.md: links to the fork-deleted docs/DEVELOPMENT.md pointed at the README Development section
- docs/test-retirements.md: ledger entries for the 12 upstream test renames (sirmalloc#697, sirmalloc#698, sirmalloc#700, sirmalloc#705, sirmalloc#713, sirmalloc#760)
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.

2 participants