Skip to content

fix: silence pagefind warnings#15

Merged
adkah merged 1 commit into
masterfrom
ak-fix-pagefind
May 13, 2026
Merged

fix: silence pagefind warnings#15
adkah merged 1 commit into
masterfrom
ak-fix-pagefind

Conversation

@adkah
Copy link
Copy Markdown
Contributor

@adkah adkah commented May 13, 2026

Get rid of noisy pagefind warnings and 404s:

15:34:09 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /pagefind/pagefind.js.
15:34:09 [404] /pagefind/pagefind.js 0ms

which came from the dev server looking for /pagefind/pagefind.js when it didn't exist.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR adds a one-line guard (if (!import.meta.env.PROD) return) to the loadPagefind effect in SearchOverlay, preventing the dev server from ever requesting /pagefind/pagefind.js — a file that only exists after a production build.

  • The fix is minimal and correctly scoped: dev mode exits early, leaving pagefindRef.current as null, so the search UI degrades gracefully (shows "No results found") without network noise.
  • The only stale artifact is the catch block comment ("Pagefind not available in dev mode"), which now incorrectly describes a scenario handled by the early return rather than the catch path.

Confidence Score: 5/5

Safe to merge — the change is a single-line early return with no logic side effects beyond disabling search in dev mode.

The change is a one-liner that correctly gates pagefind loading on import.meta.env.PROD. The only follow-up is a stale inline comment in the catch block, which has no runtime impact.

No files require special attention.

Important Files Changed

Filename Overview
src/components/search-overlay.tsx Adds a single early-return guard so pagefind is never loaded outside production builds, eliminating dev-server 404s and console warnings.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[useEffect fires on mount] --> B{import.meta.env.PROD?}
    B -- No --> C[Return early\nNo network request made]
    B -- Yes --> D[Construct pagefind URL]
    D --> E[Dynamic import pagefind.js]
    E --> F{Import success?}
    F -- Yes --> G[pf.init\npagefindRef.current = pf]
    F -- No --> H[catch block\nsilently swallowed]
    G --> I[Search available]
    C --> J[pagefindRef stays null\nSearch shows no results]
Loading

Comments Outside Diff (1)

  1. src/components/search-overlay.tsx, line 43-45 (link)

    P2 The catch comment says "Pagefind not available in dev mode", but that case is now handled by the early return above — the catch is only reached in production when the dynamic import actually fails (e.g., missing or network-unreachable /pagefind/pagefind.js). The comment is now misleading.

Reviews (1): Last reviewed commit: "fix: pagefind warnings" | Re-trigger Greptile

@adkah adkah merged commit 8722f0b into master May 13, 2026
7 checks passed
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