shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.72k stars 1.27k forks source link

nextra-theme-docs search fails with "failed to load search index" #1710

Closed dutterbutter closed 1 year ago

dutterbutter commented 1 year ago

Bug Report: Search functionality failing to load search index in deployed instance

Overview

We are currently using nextra-theme-docs for our documentation site, and the search functionality in a deployed instance is now failing to load the search index. However, the search bar works fine in a local environment.

Relevant links

Things tried

Steps to reproduce

  1. git clone https://github.com/webb-tools/webb-docs
  2. yarn install
  3. yarn dev
  4. Visit localhost:3000/docs and use the search. This WILL work in the local environment.
  5. Deploy the docs site with your preferred provider using yarn install && yarn build and publish dir as ./.next. This is where the search functionality breaks and indicates "failed to load search index."

Any suggestions here would be appreciated, and or if need more info on this report please let me know. Thanks!

dimaMachina commented 1 year ago

does it work after next build? here is an error

image
dutterbutter commented 1 year ago

@B2o5T is that on the repo I provided? Running next build gives me no error. See output below:

next build output ``` yarn next build yarn run v1.22.19 $ /Users/dut/Documents/dev/webb/webb-docs/node_modules/.bin/next build ./components/Plausible.tsx 6:7 Warning: `next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document @next/next/no-before-interactive-script-outside-document info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules info - Linting and checking validity of types [@sentry/nextjs] You are using Next.js features that run on the Edge Runtime. Please add a "sentry.edge.config.js" or a "sentry.edge.config.ts" file to your project root in which you initialize the Sentry SDK with "Sentry.init()". [nextra] Found "_app.tsx" file, refactor it to "_app.mdx" for better performance. info - Creating an optimized production build info - Compiled successfully info - Collecting page data info - Generating static pages (62/62) info - Finalizing page optimization Route (pages) Size First Load JS ┌ /_app 0 B 98.1 kB ├ ○ /404 183 B 98.2 kB ├ λ /api/subscribers 0 B 98.1 kB ├ ○ /blog 4.68 kB 207 kB ├ ○ /docs 7.63 kB 213 kB ├ ○ /docs/anchor-system/architecture 5.78 kB 208 kB ├ ○ /docs/anchor-system/deployments 4.24 kB 206 kB ├ ○ /docs/anchor-system/overview 7.95 kB 210 kB ├ ○ /docs/anchor-system/signature-bridge 5.65 kB 207 kB ├ ○ /docs/dapps/hubble-bridge/overview 8.94 kB 211 kB ├ ○ /docs/dapps/hubble-bridge/usage-guide/account 6.83 kB 209 kB ├ ○ /docs/dapps/hubble-bridge/usage-guide/deposit 8.36 kB 210 kB ├ ○ /docs/dapps/hubble-bridge/usage-guide/manage-notes 6.5 kB 208 kB ├ ○ /docs/dapps/hubble-bridge/usage-guide/transfer 8.82 kB 211 kB ├ ○ /docs/dapps/hubble-bridge/usage-guide/withdraw 10.2 kB 212 kB ├ ○ /docs/dapps/stats-dapp/overview 5.64 kB 211 kB ├ ○ /docs/dapps/stats-dapp/usage-guide/authorities 5.82 kB 208 kB ├ ○ /docs/dapps/stats-dapp/usage-guide/keys 5.63 kB 207 kB ├ ○ /docs/dapps/stats-dapp/usage-guide/proposals 6.04 kB 208 kB ├ ○ /docs/overview/glossary 9.27 kB 211 kB ├ ○ /docs/overview/overview 6.06 kB 211 kB ├ ○ /docs/overview/privacy-manifesto 6.02 kB 208 kB ├ ○ /docs/protocols/asset-transfer/governance-proposals 5.73 kB 208 kB ├ ○ /docs/protocols/asset-transfer/overview 6.74 kB 209 kB ├ ○ /docs/protocols/definitions 4.47 kB 206 kB ├ ○ /docs/protocols/dkg/authority-selection 5.31 kB 207 kB ├ ○ /docs/protocols/dkg/governance/lifecycle 5.52 kB 207 kB ├ ○ /docs/protocols/dkg/governance/pallets 5.97 kB 208 kB ├ ○ /docs/protocols/dkg/governance/proposals 5.01 kB 207 kB ├ ○ /docs/protocols/dkg/key-rotation 4.87 kB 207 kB ├ ○ /docs/protocols/dkg/misbehaviour 5.09 kB 207 kB ├ ○ /docs/protocols/dkg/overview 8.37 kB 213 kB ├ ○ /docs/protocols/identity 8.26 kB 210 kB ├ ○ /docs/relayer/data-querying 5.9 kB 208 kB ├ ○ /docs/relayer/overview 7.95 kB 213 kB ├ ○ /docs/relayer/private-tx 5.82 kB 208 kB ├ ○ /docs/relayer/roadmap 4.69 kB 207 kB ├ ○ /docs/relayer/running-relayer/cli-usage 5.12 kB 212 kB ├ ○ /docs/relayer/running-relayer/cloud-setup 7.63 kB 209 kB ├ ○ /docs/relayer/running-relayer/config-options 4.85 kB 207 kB ├ ○ /docs/relayer/running-relayer/quick-start 9.39 kB 216 kB ├ ○ /docs/relayer/running-relayer/relayer-api 5.64 kB 207 kB ├ ○ /docs/relayer/running-relayer/running-docker 10.2 kB 212 kB ├ ○ /docs/relayer/signature-relay 6 kB 208 kB ├ ○ /docs/tangle-network/node-operators/api-reference/cli 9.06 kB 216 kB ├ ○ /docs/tangle-network/node-operators/deploy-with-docker/collator-node 8.78 kB 211 kB ├ ○ /docs/tangle-network/node-operators/deploy-with-docker/full-node 7.03 kB 209 kB ├ ○ /docs/tangle-network/node-operators/deploy-with-docker/relayer-node 8.88 kB 211 kB ├ ○ /docs/tangle-network/node-operators/deploy-with-docker/validator-node 8.84 kB 211 kB ├ ○ /docs/tangle-network/node-operators/monitoring/alert-manager 9.43 kB 216 kB ├ ○ /docs/tangle-network/node-operators/monitoring/grafana 7.59 kB 214 kB ├ ○ /docs/tangle-network/node-operators/monitoring/loki 8.11 kB 215 kB ├ ○ /docs/tangle-network/node-operators/monitoring/prometheus 8.82 kB 215 kB ├ ○ /docs/tangle-network/node-operators/monitoring/quickstart 6.74 kB 213 kB ├ ○ /docs/tangle-network/node-operators/quickstart 6.45 kB 211 kB ├ ○ /docs/tangle-network/node-operators/required-keys 7.13 kB 209 kB ├ ○ /docs/tangle-network/node-operators/requirements 6.55 kB 213 kB ├ ○ /docs/tangle-network/node-operators/systemd/collator-node 6.88 kB 209 kB ├ ○ /docs/tangle-network/node-operators/systemd/full-node 5.12 kB 207 kB ├ ○ /docs/tangle-network/node-operators/systemd/validator-node 6.83 kB 209 kB ├ ○ /docs/tangle-network/node-operators/troubleshooting 5.57 kB 207 kB ├ ○ /docs/tangle-network/overview 9.83 kB 212 kB └ ○ /docs/tangle-network/payouts 5.21 kB 207 kB + First Load JS shared by all 107 kB ├ chunks/framework-695e56344d65da02.js 45.4 kB ├ chunks/main-1dfb9aaf9e003875.js 29.4 kB ├ chunks/pages/_app-3b4ac15011cd43c1.js 22.3 kB ├ chunks/webpack-3e8601c62f4d8722.js 970 B └ css/35bdbcdb1c178ca4.css 8.54 kB λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps) ○ (Static) automatically rendered as static HTML (uses no initial props) ✨ Done in 29.89s ```
anuragk15 commented 1 year ago

While next build works for me, if I run next build && next export then it throws an error in search "Failed to load search"

Here is my next.config.js

const withNextra = require('nextra')({
  theme: 'nextra-theme-docs',
  //theme: './theme.tsx',
  themeConfig: './theme.config.jsx',

})

module.exports = {
  ...withNextra({}),
  images: {
    unoptimized: true,
    domains: ['www.locofy.ai'],
  },

  assetPrefix: './'
}
dutterbutter commented 1 year ago

Resolved the issue by updating deps.

lucas-labs commented 1 year ago

@dutterbutter By any chance do you remember what dep was causing this? I'm facing the same error, but after updating my deps, the error persists.

The browser shows a 404 trying to get nextra-data-en-US.json, just like in the screenshot posted by B2o5T

dutterbutter commented 1 year ago

@lucas-labs I can't speak to the 404 trying to get nextra-data-en-US.json as I did not experience that. However if I recall correctly the deps we used were:

    "next": "^13.0.0",
    "next-themes": "^0.2.0",
    "nextra": "^2.0.1",
    "nextra-theme-docs": "^2.0.1",

We also had to fix the an mdx file that was incorrectly formatted to resolve the search index issue. Hope that helps!