Skip to content

fix(search): replace stale records when saving an index - #2817

Open
xu91102 wants to merge 1 commit into
docsifyjs:developfrom
xu91102:fix/search-remove-expired-records
Open

xu91102 wants to merge 1 commit into
docsifyjs:developfrom
xu91102:fix/search-remove-expired-records

Conversation

@xu91102

@xu91102 xu91102 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Deleted or renamed sections can return in search results after an expired index has been rebuilt and the site is opened again.

The refresh correctly rebuilds INDEXES in memory, but bulkPut() only inserts or updates records. Old slugs remain in IndexedDB while the cache expiry is renewed. The next visit reads those obsolete records back alongside the current index.

Replace the current indexKey's records and update its expiry in one Dexie transaction. Other namespaces are retained, and there is no database schema change.

Reproduction

  1. Index a page containing # Obsolete and a unique search term.
  2. Let the search cache expire, then remove or rename that section in the document.
  3. Open the site: the rebuilt in-memory index correctly omits the old section.
  4. Open the site again before the new cache expires: previously, the removed section returned from IndexedDB.

The browser regression follows these visits through the actual search UI, using maxAge: -1 for the first visit to expire the initial cache deterministically. A separate regression verifies that saving one namespace retains another namespace's valid cache.

Related issue, if any:

Reproduced on develop at d823dbe51c1b2dea4c2091e2b952ded0d1e16616; no matching open fix found.

What kind of change does this PR introduce?

  • Bugfix

For any code change,

  • Related documentation has been updated, if needed (no configuration or public API change)
  • Related tests have been added or updated

Does this PR introduce a breaking change?

  • No

Validation

  • The browser regression failed before the fix: the third visit showed the deleted Obsolete section. It passes after the fix.
  • npm run test:e2e:chromium -- test/e2e/search.test.js --workers=2 --reporter=line: 21 tests passed.
  • npm run test:jest -- --runInBand: 128 tests and 46 snapshots passed.
  • npm run build, npm run lint, npm run typecheck, and git diff --check: passed.
  • Independent read-only review of the fixed diff found no required changes.

Browser coverage: Chromium via Playwright. Firefox, WebKit, unrelated E2E suites, and transaction-failure fault injection were not run locally.

Developed with assistance from OpenAI Codex; the regression and fix were validated locally.

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant