Skip to content

fix(astro): mirror batch-size override and ECONNRESET retry to full-reindex script#134

Merged
chris-c-thomas merged 1 commit intomainfrom
fix/full-reindex-batch-and-retry
Apr 25, 2026
Merged

fix(astro): mirror batch-size override and ECONNRESET retry to full-reindex script#134
chris-c-thomas merged 1 commit intomainfrom
fix/full-reindex-batch-and-retry

Conversation

@chris-c-thomas
Copy link
Copy Markdown
Owner

Summary

Mirror of #133 to the full-reindex sibling. apps/astro/scripts/index-search.ts now has the same surface as index-search-incremental.ts:

  • --batch-size <n> CLI flag and MEILI_BATCH_SIZE env var override the default 500 docs/batch
  • --verbose-batches logs first/last doc ID of every flushed batch (stdout force-flushed)
  • flushWithRetry() handles ECONNRESET during Meilisearch OOM crashes by waiting on /health and retrying on the original taskUid

Why

apps/astro/CLAUDE.md says these two scripts must be kept in sync — same sources, same SearchDocument shape, same configureIndex settings. #133 only updated the incremental sibling because that's the script that was field-validated on the VPS. This PR closes the drift before it bites someone running a full reindex.

The full reindex is rarely run, but when it is run it's the operation most exposed to OOM (it writes ~1M docs in one pass with no per-source checkpointing). The retry path is exactly the kind of thing you want already in place by the time you need it.

Test plan

  • npx tsx scripts/index-search.ts --batch-size abc rejects non-integer
  • MEILI_BATCH_SIZE=xyz npx tsx scripts/index-search.ts rejects non-integer
  • pnpm turbo build:astro passes
  • Pre-existing typecheck errors (gray-matter cache) unrelated and unchanged
  • Run a real full reindex with --batch-size 100 --verbose-batches on the next full rebuild to confirm the retry path

…eindex script

apps/astro/scripts/index-search.ts gets the same treatment that
index-search-incremental.ts received in #133:

- New --batch-size <n> CLI flag and MEILI_BATCH_SIZE env var override
  the default of 500 docs/batch.
- New --verbose-batches flag prints first/last doc ID per flushed batch
  with stdout force-flushed so the last logged ID survives a crash.
- New flushWithRetry() in BatchIndexer waits for /health to return
  "available" (up to 180s) and retries on the original taskUid rather
  than resubmitting. Up to 5 attempts per flush.

apps/astro/CLAUDE.md says these two scripts must be kept in sync —
this PR closes the drift introduced when #133 only updated the
incremental sibling.

Behavior identical to #133. Tested:
- npx tsx scripts/index-search.ts --batch-size abc → rejects non-integer
- MEILI_BATCH_SIZE=xyz npx tsx scripts/index-search.ts → rejects non-integer
- pnpm turbo build:astro → passes
@chris-c-thomas chris-c-thomas merged commit 2ff98dc into main Apr 25, 2026
6 checks passed
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
72.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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