docusaurus-lunr-search icon indicating copy to clipboard operation
docusaurus-lunr-search copied to clipboard

Unhandled Rejection (TypeError): Cannot read property 'forEach' of undefined

Open karan-vk opened this issue 4 years ago • 2 comments

Function.lunr.Pipeline.load C:\Users\Karan\Desktop\TargeV2\rust-doc\node_modules\lunr\lunr.js:575 572 | lunr.Pipeline.load = function (serialised) { 573 | var pipeline = new lunr.Pipeline 574 |

575 | serialised.forEach(function (fnName) { 576 | var fn = lunr.Pipeline.registeredFunctions[fnName] 577 | 578 | if (fn) { View compiled Function.lunr.Index.load C:\Users\Karan\Desktop\TargeV2\rust-doc\node_modules\lunr\lunr.js:2286 2283 | invertedIndex = Object.create(null), 2284 | serializedInvertedIndex = serializedIndex.invertedIndex, 2285 | tokenSetBuilder = new lunr.TokenSet.Builder, 2286 | pipeline = lunr.Pipeline.load(serializedIndex.pipeline) | ^ 2287 | 2288 | if (serializedIndex.version != lunr.version) { 2289 | lunr.utils.warn("Version mismatch when loading serialised index. Current version of lunr '" + lunr.version + "' does not match serialized index '" + serializedIndex.version + "'") View compiled new LunrSearchAdapter webpack-internal:///./src/theme/SearchBar/lib/lunar-search.js:3:266 new DocSearch C:/Users/Karan/Desktop/TargeV2/rust-doc/src/theme/SearchBar/lib/DocSearch.js:141 138 | /** 139 | * Returns the source method to be passed to autocomplete.js. It will query 140 | * the Algolia index and call the callbacks with the formatted hits. 141 | * @function getAutocompleteSource | ^ 142 | * @param {function} transformData An optional function to transform the hits 143 | * @param {function} queryHook An optional function to transform the query 144 | * @returns {function} Method to be passed as the source option of

Getting this error when following the guide help please !!!!!!!!

karan-vk avatar Oct 15 '20 19:10 karan-vk

From the README

Note: Docusaurus search information can only be generated from a production build. Local development is currently not supported.

So I think you'll need to do npm run serve to test out the search functionality.

That said, any chance you can add some null checks to prevent the exception? I'm good not having search enabled in dev mode, but sometimes I accidentally mouse over the search box and get presented with the error screen.

EDIT: Ah just saw a workaround in #33

cocco3 avatar Jan 08 '21 19:01 cocco3

That's it, it worked for me, but should we worry about the current Docusaurus swizzle caution for v2 in the near future?

jeff-pal avatar Jan 13 '21 19:01 jeff-pal