docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.42k stars 5.67k forks source link

Search Plugin Not Working #1400

Closed Ares-X closed 10 months ago

Ares-X commented 3 years ago

Bug Report

Steps to reproduce

fist time open docsify website , search plugin is working correct , after click some page , search-min.js throw error ,and search plugin not working any more , type something to search won't get any thing response

What is current behaviour

when open some page

search.min.js:1 Uncaught TypeError: Cannot read property '/./IOT%E5%AE%89%E5%85%A8/360/360%20Phone%20N6%20Pro%E5%86%85%E6%A0%B8%E6%BC%8F%E6%B4%9E' of null
    at search.min.js:1
    at Array.forEach (<anonymous>)
    at i (search.min.js:1)
    at search.min.js:1
    at o (docsify.min.js:1)
    at o (docsify.min.js:1)
    at B (docsify.min.js:1)
    at r (docsify.min.js:1)
    at docsify.min.js:1
    at docsify.min.js:1

image

type something to search

search.min.js:1 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at c (search.min.js:1)
    at r (search.min.js:1)
    at search.min.js:1

image

What is the expected behaviour

Other relevant information

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)

Koooooo-7 commented 3 years ago

Could u make it in Sandbox or ur site where it can be reproduced? Due to the console err, it seems not clearly.

Ares-X commented 3 years ago

here is my website https://ares-x.com/wiki/ password: qaxniubi open some page and wait a while , search will not working image

sy-records commented 3 years ago

Modify the search plugin to search.js. Don't use min so we can check for errors!

Change the path to English and try again. https://ares-x.com/wiki/_sidebar.md

Refer to docsify's sidebar document. https://docsify.js.org/_sidebar.md

Koooooo-7 commented 3 years ago

According to the console information, I doubt that your files of ur site r too much to be stored in the LocalStorage as search.index. 😅 Could you remove the most of contents and hv a test again. Waiting for ur feedback.

Ares-X commented 3 years ago

According to the console information, I doubt that your files of ur site r too much to be stored in the LocalStorage as search.index. 😅 Could you remove the most of contents and hv a test again. Waiting for ur feedback.

maybe that's true , this problem doesn't happened on my mac , seem like only effect windows or mobile device?

Ares-X commented 3 years ago

i delete a lot of contents , then work fine on windows device , so is there any way to solve this problem?

sy-records commented 3 years ago

see https://github.com/docsifyjs/docsify/issues/1400#issuecomment-709657743

You can convert the path to English to reduce the occupation.

Ares-X commented 3 years ago

see #1400 (comment)

You can convert the path to English to reduce the occupation.

image i don't think is chinese path cause this error, i have tried many time on local server ,it doesn't have any problem i already changed search-min.js to search.js it seems like working correct now

sy-records commented 3 years ago

I'm just suggesting, otherwise your url would be long.

Ares-X commented 3 years ago

thanks for help

Koooooo-7 commented 3 years ago

Is the issue still exsit? I guess we need investigation more about it. Could u reset ur site to make the exception reproduciable? thx in advance. IIRC,the localstorage size is relatived to the browser, I m not sure what makes the difference on different OS. r they the same browsers which u used on Win and Mac? AFAIK, We havent a solution about it yet, actully, I guess we havnt thought about such a big content in docsify. 🤫

Ares-X commented 3 years ago

Is the issue still exsit? I guess we need investigation more about it. Could u reset ur site to make the exception reproduciable? thx in advance. IIRC,the localstorage size is relatived to the browser, I m not sure what makes the difference on different OS. r they the same browsers which u used on Win and Mac? AFAIK, We havent a solution about it yet, actully, I guess we havnt thought about such a big content in docsify. 🤫

after i changed search-min.js to search.js this problem seem doesn't exist

i used chrome on my mac and win , macos works fine ,but windows has this problem, and i also told my friend to try it ,use firefox and chrome on his windows device , he also have this problem

here is the old version to reproduce this bug https://ares-x-github-io-41iddeg6s.vercel.app/wiki/ pass:qaxniubi use chrome on windows open it , at the first time search won't have problem, click some page and wait a monment , open f12 console and try to search anything ,you will see those error i post before

image

Koooooo-7 commented 3 years ago

after i changed search-min.js to search.js this problem seem doesn't exist

It seems weird. 😅

thx again, we will check it and make sure what happened actually.

cc @anikethsaha PTAL, I think there should have something needs be digged out.

Ares-X commented 3 years ago

by the way , ios device still have this problem after changed to search.js try here https://ares-x.com/wiki/ device: iphone 6s plus ios version: 13.7

anikethsaha commented 3 years ago

after i changed search-min.js to search.js this problem seem doesn't exist

It seems weird. 😅

thx again, we will check it and make sure what happened actually.

cc @anikethsaha PTAL, I think there should have something needs be digged out.

yea....we need to have a look in it.

Koooooo-7 commented 3 years ago

FYI. I increased the localstorage size 10 times larger and got the search.index size ( 5411729 bytes, more than 5M). image

anikethsaha commented 3 years ago

weird, from which version this is happening ?

Koooooo-7 commented 3 years ago

weird, from which version this is happening ?

IMHO, I think the problem since we set the search.index in local storage. As we all know, the browsers have default local storage size (about 5 M), and we stored all the markdown files strings as search.index in local storage. If the files strings r humongous (more than 5 M), we can't set it in the local storage and cause the search err aboved.

Ares-X commented 3 years ago

weird, from which version this is happening ?

IMHO, I think the problem since we set the search.index in local storage. As we all know, the browsers have default local storage size (about 5 M), and we stored all the markdown files strings as search.index in local storage. If the files strings r humongous (more than 5 M), we can't set it in the local storage and cause the search err aboved.

https://github.com/wzpan/hexo-generator-search

Maybe you can refer to this save all markdown file strings to a local xml file

Anilople commented 3 years ago
    window.$docsify = {
      loadSidebar: true,
      ....
    }

when loadSidebar is true, the search work again, and just the content was indexed in side bar's reference.

If the content not in side bar‘s reference, they can't be searched.

So strange.

In my project, record it. https://anilople.github.io/find-spirit/#/

sy-records commented 3 years ago

@Anilople You mean you can't search there?

image

This one? If so, then it's fixed.

Anilople commented 3 years ago

@sy-records

Yes.

Let me give more example.

content can't be search

find

find

移动

移动

content can be search

ele

ele

world

world

sy-records commented 3 years ago

fixed via #1391

Anilople commented 3 years ago

fixed via #1391

My docsify version is 4.11.6

Found that there is no code describe like #1391 in my docsify/lib/plugins/search.js file. So the problem occur.

sy-records commented 3 years ago

Yes, the official version has not been released yet. You can try to build it yourself.

mengsanit commented 3 years ago

mengsanit168@gmail.com

CircArgs commented 10 months ago

@sy-records I noticed you cited a fix, and this issue is still open. I am getting a set of errors that appear extremely similar to those of this issue:

docsify.min.js:1 Docsify plugin error TypeError: Cannot read properties of null (reading '/')
    at VM6904 search.js:347:17

 ... lots more 

VM6904 search.js:208 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at search (VM6904 search.js:208:12)
    at doSearch (VM6904 search.js:402:18)
    at VM6904 search.js:440:49

Loading in the bare search.js and poking around, the error stems from these lines:

    Object.keys(INDEXS).forEach(function (key) {
      data = data.concat(Object.keys(INDEXS[key]).map(function (page) { return INDEXS[key][page]; }));
    });

INDEXS is null for some reason.

I've tried multiple paths configurations and inspected many of the awesome-docsify sites and can't spot any real differences with my setup here: https://github.com/CircArgs/cppfront

Any help would be greatly appreciated! Thank you

sy-records commented 10 months ago

@CircArgs I didn't reproduce your question. If you're using GitHub Pages, you should try setting basePath: 'cppfront'

image

If you still have problems you can resubmit a new issue instead of replying here and I will close this.

CircArgs commented 10 months ago

@sy-records Thanks for trying! I was testing on Brave. It seems it was a permission issue. Worked on Chrome. Thanks again.