Skip to content

fix: bound ix map background refresh (single-flight + deadline)#290

Merged
josephismikhail merged 1 commit into
mainfrom
fix/map-single-flight-and-deadline
Jun 11, 2026
Merged

fix: bound ix map background refresh (single-flight + deadline)#290
josephismikhail merged 1 commit into
mainfrom
fix/map-single-flight-and-deadline

Conversation

@josephismikhail

Copy link
Copy Markdown
Contributor

What

ix map runs both interactively and as an automatic background refresh (editor/agent hooks re-map on change). Repeated or overlapping invocations could stack and run unbounded against a slow backend. This makes the refresh safe to run frequently.

Changes

  • CLI-level single-flight lock (single-flight.ts): one ix map per workspace at a time. A concurrent invocation coalesces and exits 0 instead of stacking. The lock auto-releases on exit and a stale lock (dead or aged-out holder) is stolen, so it never wedges. Holds regardless of launcher (hook, watcher, manual, CI).
  • Hard wall-clock deadline shared across every ingest/map request, so a single run is always bounded even when the backend stalls on long per-request timeouts. Previously-untimed list/source-hashes/stitch requests now get a per-request timeout too. Tunable via IX_MAP_DEADLINE_MS (0 disables).
  • Abort-aware retry: a deadline/timeout abort is no longer treated as retryable, so the deadline actually stops work.
  • Skip automatic refresh on a remote backend: when invoked automatically (IX_AUTO_MAP=1), ix map skips if the active backend is remote — remote ingestion should be deliberate, not a write on every change from every client. Manual ix map is unaffected; IX_AUTO_MAP_CLOUD=1 opts the automatic path back in.

Tests

New unit tests for the single-flight lock, abort-aware retry, and auto-skip decision. Full suite: 532 passed / 2 skipped.

🤖 Generated with Claude Code

`ix map` runs both interactively and as an automatic background refresh
(editor/agent hooks re-map on change). Repeated or overlapping invocations
could stack and run unbounded against a slow backend. Make the refresh safe:

- CLI-level single-flight lock per workspace: concurrent `ix map` runs
  coalesce instead of stacking; stale locks (dead/aged holder) self-heal.
- Hard wall-clock deadline shared across every ingest/map request, so a
  single run is always bounded even when the backend stalls; previously
  untimed list/source-hashes/stitch requests now get a per-request timeout.
- Retry is abort-aware: a deadline/timeout abort is no longer retried.
- Skip the automatic refresh (IX_AUTO_MAP=1) when the active backend is
  remote; remote ingestion should be deliberate. Manual `ix map` is
  unaffected; opt in with IX_AUTO_MAP_CLOUD=1.

Adds unit tests for the lock, abort-aware retry, and auto-skip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@josephismikhail josephismikhail changed the title Bound ix map background refresh: single-flight + deadline fix: bound ix map background refresh (single-flight + deadline) Jun 11, 2026
@josephismikhail josephismikhail merged commit 495bd74 into main Jun 11, 2026
20 of 21 checks passed
@josephismikhail josephismikhail deleted the fix/map-single-flight-and-deadline branch June 11, 2026 04:17
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