fix(search): save index even when some pages fail to load#2689
Open
Bowl42 wants to merge 4 commits intodocsifyjs:developfrom
Open
fix(search): save index even when some pages fail to load#2689Bowl42 wants to merge 4 commits intodocsifyjs:developfrom
Bowl42 wants to merge 4 commits intodocsifyjs:developfrom
Conversation
When the search plugin indexes pages in auto mode, if any page fails to load (e.g. 404), the fetch promise rejects with no error handler. This means `count` never reaches `len`, so `saveData` is never called and the entire search index is lost — even for pages that loaded successfully. Add an error handler to the `.then()` call that still increments the counter, ensuring the search index is saved with whatever pages were successfully fetched. Fixes docsifyjs#2674 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@Bowl42 is attempting to deploy a commit to the Docsify Team on Vercel. A member of the Team first needs to authorize it. |
Add console.warn so that failed fetches are visible in the developer console, making it easier to debug missing search results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The custom ajax `.then(success, error)` passes `(event, responseStatus)` not a standard Error. Use the response status for a more useful warning message, e.g. "(404)" instead of logging a ProgressEvent object. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Docsify.get().then()insearch.jshas no rejection handler. When a fetch fails,countis never incremented for that path, socountnever reacheslen, andsaveData()is never called..then()that logs a warning and incrementscount, ensuringsaveData()is called once all paths have been attempted.Changes
src/plugins/search/search.js:.then()call, matching the custom ajax signature(_event, response)console.warnwith the failed path and HTTP status code (e.g.[Docsify] Failed to fetch /broken-page for search indexing (404)) for easier debuggingcountso thatsaveData()is still called when all fetches complete, preserving the index for pages that loaded successfullyTest plan
autoindexing.mdfile)Fixes #2674
🤖 Generated with Claude Code