Skip to content

fix(ci): Restore Algolia indexing under tsx and smoke-test it on PRs#18265

Open
sergical wants to merge 4 commits into
masterfrom
sergical/fix-algolia-tsx-resolution
Open

fix(ci): Restore Algolia indexing under tsx and smoke-test it on PRs#18265
sergical wants to merge 4 commits into
masterfrom
sergical/fix-algolia-tsx-resolution

Conversation

@sergical
Copy link
Copy Markdown
Member

@sergical sergical commented Jun 4, 2026

DESCRIBE YOUR PR

Restores the Update Algolia index workflow, which has been failing on master for every docs-touching push since the Bun→tsx runner swap in #17772.

Root cause: tsx loads scripts/algolia.ts through Node's CJS resolver. The script transitively imports rehype-prism-diff (via src/mdx.ts), and that package's exports map declares only an "import" condition — so the CJS resolver fails with ERR_PACKAGE_PATH_NOT_EXPORTED. Bun tolerated this; tsx does not. (The earlier OOM fixes — #17283/#17711/#17722 — addressed a different, now-resolved failure mode.)

Why it kept slipping through: the workflow only ran on push: master, so there was never any PR-time signal. #17772 touched only the workflow file and landed green.

Changes

  • scripts/tsconfig.json (new): scoped tsconfig that aliases rehype-prism-diff to its real dist/index.js, so tsx resolves it as a plain file and bypasses the import-only exports map. Doesn't touch the Next.js build.
  • algolia-index.yml: both tsx invocations now pass --tsconfig ./scripts/tsconfig.json.
  • Prevention: added a pull_request trigger gated to the indexing machinery (workflow, script, tsconfig, src/mdx.ts, package.json, lockfile) that builds + dry-runs the indexer with no secrets and no upload. The very PR that broke this would have failed under this setup.
  • scripts/algolia.ts: added an ALGOLIA_DRY_RUN guard powering the smoke test; the real upload path is unchanged when the flag is unset.

Verification

  • Reproduced the exact CI error locally, confirmed --tsconfig resolves the full import graph.
  • Dry-run runs end-to-end with no secrets (🧪 Dry run … ✅ Done).
  • prettier + eslint clean on changed files. (Note: lint:ts has 3 preexisting errors in src/instrumentation*.ts unrelated to this PR.)

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

The Bun->tsx runner swap (#17772) broke the Algolia index workflow on
master. tsx loads scripts/algolia.ts via Node's CJS resolver, which
fails on rehype-prism-diff (imported transitively via src/mdx.ts)
because that package's `exports` map only declares an "import"
condition: ERR_PACKAGE_PATH_NOT_EXPORTED. Bun tolerated this; tsx does
not. Every docs-touching push has failed this step since the swap.

Alias rehype-prism-diff to its real dist file in a scoped
scripts/tsconfig.json so tsx resolves it as a plain file and bypasses
the exports map, without affecting the Next.js build.

The workflow only ran on push to master, so the regression had no
pre-merge signal. Add a pull_request trigger gated to the indexing
machinery (workflow, script, tsconfig, src/mdx.ts, package.json,
lockfile) that builds and dry-runs the indexer with no secrets, so a
future runner/dependency change is caught in PR CI. Add an
ALGOLIA_DRY_RUN guard to the script to support this without mutating
the production index.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment Jun 5, 2026 4:48pm
sentry-docs Ready Ready Preview, Comment Jun 5, 2026 4:48pm

Request Review

The PR smoke test ran the indexer over the full ~10k-page corpus with a
cold cache, exhausting the heap. The real (push) job survives because
its .next/cache/algolia-records content-hash cache stays warm across
runs; a cold PR run does not.

The smoke test only needs to prove the script builds and its import
graph resolves, so cap dry-run processing to a bounded page sample,
skip stale-cache cleanup in dry-run (a partial run must not delete real
cache entries), and drop the shared cache step from the smoke job so it
can never read or poison the push job's warm cache.

Co-Authored-By: Claude <noreply@anthropic.com>
The smoke test ran a full ~10k-page `next build` (6-8 min) before the
dry-run, but the regression it guards against -- the script and its
import graph failing to resolve under the runner -- happens at module
load, with no build required. Build-output correctness is already
covered by Vercel's PR preview deploy.

Run only the dry-run script (with ALGOLIA_SKIP_ON_ERROR so the absent
.next HTML is tolerated). The job drops from minutes to ~1 minute while
still catching runner/dependency-resolution regressions.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread .github/workflows/algolia-index.yml Outdated
run: npx tsx --tsconfig ./scripts/tsconfig.json ./scripts/algolia.ts
env:
ALGOLIA_DRY_RUN: 'true'
ALOGOLIA_SKIP_ON_ERROR: 'true'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in here (not introduced by you) but let's fix it.

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