Skip to content

fix(build): don't block deploys when Algolia sync fails - #145

Merged
majinghe merged 1 commit into
rustfs:mainfrom
majinghe:fix/algolia-sync-non-blocking
Sep 20, 2026
Merged

majinghe merged 1 commit into
rustfs:mainfrom
majinghe:fix/algolia-sync-non-blocking

Conversation

@majinghe

Copy link
Copy Markdown
Collaborator

Problem

The Cloudflare production build for #144 failed after generating all 2515 pages — at the final sync-algolia.mjs step:

ApiError: This operation cannot be processed, the application is blocked. Contact us to unblock it.

Because the sync runs inside npm run build, the whole build was marked failed and the deploy was never published — merged docs (including the capo guide) are not live yet.

Fix

scripts/sync-algolia.mjs:

  1. Non-fatal sync: catch Algolia errors and exit 0 with a warning — a search re-index hiccup should never block publishing the docs themselves. The index simply stays stale until the account issue is resolved.
  2. Skip preview builds: when CF_PAGES_BRANCH is set and isn't main, skip the sync. Each PR preview currently re-indexes all ~2.5k pages, burning Algolia operations — the likely cause of the application block in the first place.

Verification

  • node --check scripts/sync-algolia.mjs — OK
  • No ALGOLIA_ADMIN_API_KEY → skipped, exit 0 (unchanged behavior)
  • CF_PAGES_BRANCH=docs/capo-integration + key set → skipped, exit 0 (new)
  • Simulated Algolia rejection (invalid key, same ApiError failure mode) → warns and exits 0; deploy continues (new)
  • Successful-sync path unchanged

Follow-ups (outside this repo)

  • Unblock the Algolia application L2SE8QG99N (contact Algolia support / check billing & quota). Until then, on-site search may also be affected even after this deploy publishes.
  • Rotate the Algolia admin API key: it appeared in a build log (request header dump).

The Algolia sync step ran inside 'npm run build' and any Algolia API
error (the app is currently blocked: 'This operation cannot be
processed, the application is blocked') failed the whole Cloudflare
build, so merged docs never got published. Catch sync errors and
continue deploying; the search index just stays stale until the
account issue is resolved.

Also skip the sync on Cloudflare preview builds (CF_PAGES_BRANCH !=
main). Each preview re-indexed all ~2.5k pages and burned the Algolia
operation quota, which is the likely cause of the block.

Verified locally: no-key skip, preview-branch skip, and an Algolia
ApiError (invalid key) all exit 0 with a log line; successful sync
behavior is unchanged.
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

@majinghe is attempting to deploy a commit to the overtrue's projects Team on Vercel.

A member of the Team first needs to authorize it.

@majinghe
majinghe merged commit b55db09 into rustfs:main Sep 20, 2026
1 check failed
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