Skip to content

MiniSearch: duplicate ID error when restarting the dev server (Duplicate for #4251) #4688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
Teraskull opened this issue Apr 14, 2025 · 3 comments
Open
4 tasks done

Comments

@Teraskull
Copy link

Teraskull commented Apr 14, 2025

Describe the bug

Hi,

Opening a duplicate issue here as the original one is locked.
 
Are there any plans for issue #4251? It got automatically closed by the bot but is still an annoying problem.

While the PR in that issue won't handle replacing headers because their anchor id would change, it is still helpful not having to reload the server manually each time after incremental markdown changes when testing the search functionality.

Thanks!

Reproduction

N/A

Expected behavior

N/A

System Info

N/A

Additional context

No response

Validations

@Teraskull Teraskull added the bug: pending triage Maybe a bug, waiting for confirmation label Apr 14, 2025
@brc-dd
Copy link
Member

brc-dd commented Apr 14, 2025

Feel free to recreate that PR. It got closed because the original author deleted their account.

it is still helpful not having to reload the server manually each time after incremental markdown changes when testing the search functionality

Can you share the case where this happens? I think it shouldn't be needed for markdown changes. In original issue, they were using vite's server.restart inside custom plugin that was causing the issue.

@Teraskull
Copy link
Author

Basically, if I do a lot of small changes in a markdown segment, like rewriting/rewording, and want to preview how it looks when searching for the segment, the id of the segment already exists in the cache, so Minisearch throws an error about a duplicate id.

Having the server reload automatically on these changes allows to rebuild the search cache and display fresh changes in the search details.

It's not a big change, this is the whole code from the PR:

if (index.has(id)) {
    index.discard(id)
}

I know this is a very minor issue and more of a nitpick, but sometimes I need to test if it's intuitive enough for my users to find a section by keywords, without having to manually restart docs:dev after every change for the search cache to get refreshed.

Unless there is a better way of course, thanks!

@brc-dd brc-dd removed the bug: pending triage Maybe a bug, waiting for confirmation label Apr 14, 2025
@brc-dd
Copy link
Member

brc-dd commented Apr 14, 2025

I've to do some refactors for the search plugin. I'll fix this there itself. The search index should be partially rebuilt on md changes. For now, I'd say bear with the issue for some more time. Also, you don't need to manually re-run docs:dev, you can just press r in terminal.

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

No branches or pull requests

2 participants