Skip to content
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

bug: Repeated builds will result in incorrect cache #3363

Open
4 tasks done
rxliuli opened this issue Dec 20, 2023 · 3 comments · Fixed by #3398
Open
4 tasks done

bug: Repeated builds will result in incorrect cache #3363

rxliuli opened this issue Dec 20, 2023 · 3 comments · Fixed by #3398
Labels
bug Something isn't working stale

Comments

@rxliuli
Copy link

rxliuli commented Dec 20, 2023

Describe the bug

I'm using vitepress's nodejs api, but one problem is that if I call build twice, the second time there will be the wrong cache, causing the built index.html to still be the old result from the first time.

import { mkdir, readFile, writeFile } from 'fs/promises'
import path from 'path'
import { build } from 'vitepress'
import { it, expect } from 'vitest'

const tempPath = path.resolve(__dirname, '.temp')

it('should build', async () => {
  await mkdir(tempPath, { recursive: true })
  await writeFile(path.resolve(tempPath, 'index.md'), '# test 1')
  await build(tempPath, {
    outDir: path.resolve(tempPath, 'dist'),
  })
  expect(
    await readFile(path.resolve(tempPath, 'dist/index.html'), 'utf-8'),
  ).include('test 1')
  await writeFile(path.resolve(tempPath, 'index.md'), '# test 2')
  await build(tempPath, {
    outDir: path.resolve(tempPath, 'dist'),
  })
  expect(
    await readFile(path.resolve(tempPath, 'dist/index.html'), 'utf-8'),
  ).include('test 2') // AssertionError: expected '<!DOCTYPE html>\n<html lang="en-US" d…' to include 'test 2'
})

Reproduction

  1. git clone https://github.com/rxliuli/vitepress-error-demo
  2. pnpm i
  3. pnpm vitest

Expected behavior

The cache should be cleared during the second build

System Info

System:
    OS: macOS 13.3
    CPU: (12) arm64 Apple M2 Max
    Memory: 10.56 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.12.1 - /usr/local/bin/pnpm
    Watchman: 2023.08.14.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 115.1.56.11
    Chrome: 120.0.6099.109
    Safari: 16.4
  npmPackages:
    vitepress: 1.0.0-rc.32 => 1.0.0-rc.32

Additional context

No response

Validations

@rxliuli rxliuli added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 20, 2023
@brc-dd brc-dd closed this as completed in 9568fea Dec 26, 2023
@rxliuli
Copy link
Author

rxliuli commented Jan 1, 2024

@brc-dd There is no fix. The above error can still be reproduced after upgrading to the latest version 1.0.0-rc.34

@brc-dd brc-dd reopened this Jan 1, 2024
@brc-dd
Copy link
Member

brc-dd commented Jan 1, 2024

Looks like that markdown cache is not causing this. Some other step is caching stuff.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2024
@brc-dd brc-dd reopened this Aug 5, 2024
@vuejs vuejs unlocked this conversation Aug 5, 2024
brc-dd added a commit that referenced this issue Aug 5, 2024
@brc-dd brc-dd added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Aug 5, 2024
@brc-dd
Copy link
Member

brc-dd commented Aug 5, 2024

This is reopened because the related PR is reverted. It didn't actually fix the issue and caused other issues. Based on the discussions on nodejs/help#1399, I think the only feasible way is to use a separate worker thread for this. Adding queries to imports to bust cache has memory leaks and it doesn't modify the nested modules which in turn results in re-execution of modules. This is problematic for modules such as the app entrypoint as they have side-effects like symbol initializations that change when something is run twice.

@github-actions github-actions bot added the stale label Sep 29, 2024
OCram85 pushed a commit to OCram85/arkanum that referenced this issue Oct 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [vitepress](https://vitepress.dev/) ([source](https://github.com/vuejs/vitepress)) | devDependencies | minor | [`1.3.4` -> `1.4.1`](https://renovatebot.com/diffs/npm/vitepress/1.3.4/1.4.1) |

---

### Release Notes

<details>
<summary>vuejs/vitepress (vitepress)</summary>

### [`v1.4.1`](https://github.com/vuejs/vitepress/blob/HEAD/CHANGELOG.md#141-2024-10-13)

[Compare Source](vuejs/vitepress@v1.4.0...v1.4.1)

##### Bug Fixes

-   broken rewrites on windows ([#&#8203;4268](vuejs/vitepress#4268)) ([b46d6d3](vuejs/vitepress@b46d6d3))
-   **client:** use `usePreferredDark` with `appearance: "force-auto"` ([#&#8203;4263](vuejs/vitepress#4263)) ([3e8fc40](vuejs/vitepress@3e8fc40))
-   **client:** wrong script async check ([461a5b0](vuejs/vitepress@461a5b0))
-   **theme:** bind missing no icon prop in the menu link component [#&#8203;4260](vuejs/vitepress#4260) ([b96712c](vuejs/vitepress@b96712c))
-   **theme:** improve local search input a11y ([#&#8203;4066](vuejs/vitepress#4066)) ([92b92ae](vuejs/vitepress@92b92ae))

##### Features

-   **experimental:** support passing function for rewrites ([#&#8203;4274](vuejs/vitepress#4274)) ([8436472](vuejs/vitepress@8436472))

### [`v1.4.0`](https://github.com/vuejs/vitepress/blob/HEAD/CHANGELOG.md#140-2024-10-07)

[Compare Source](vuejs/vitepress@v1.3.4...v1.4.0)

##### Bug Fixes

-   `vueRE` conflicting with `lineNoRE` ([#&#8203;4247](vuejs/vitepress#4247)) ([2ac64b8](vuejs/vitepress@2ac64b8))
-   hmr not updating page data in rewritten paths and file path is wrong in mdit for dynamic routes ([c46e4b7](vuejs/vitepress@c46e4b7)), closes [#&#8203;4172](vuejs/vitepress#4172)
-   remove font synthesis in webfont mode, google fonts now support italic axis in inter ([1628918](vuejs/vitepress@1628918))
-   **theme:** change the order of CSS rules of `VPFlyout` ([#&#8203;4225](vuejs/vitepress#4225)) ([68150a6](vuejs/vitepress@68150a6)), closes [#&#8203;4224](vuejs/vitepress#4224)
-   **theme:** respect custom tag prop in VPButton component ([#&#8203;4185](vuejs/vitepress#4185)) ([9c5d348](vuejs/vitepress@9c5d348))

##### Features

-   add `data-title` attribute for code group label tag ([#&#8203;4152](vuejs/vitepress#4152)) ([bc7271d](vuejs/vitepress@bc7271d))
-   allow ignoring certain headers and their subtrees completely in outline ([3e11b6a](vuejs/vitepress@3e11b6a)), closes [#&#8203;4171](vuejs/vitepress#4171)
-   **client:** add `onAfterPageLoad` hook in router ([#&#8203;4126](vuejs/vitepress#4126)) ([315c220](vuejs/vitepress@315c220))
-   support adding extra attributes to snippet imports (useful for twoslash) ([#&#8203;4100](vuejs/vitepress#4100)) ([e8f7dd1](vuejs/vitepress@e8f7dd1))
-   **theme:** expose theme default VPLink & VPSocialLink(s) component ([#&#8203;4178](vuejs/vitepress#4178)) ([615e33b](vuejs/vitepress@615e33b))
-   trigger `onContentUpdated` on frontmatter-only changes too ([0db269a](vuejs/vitepress@0db269a))

#### [1.3.4](vuejs/vitepress@v1.3.3...v1.3.4) (2024-08-24)

##### Bug Fixes

-   check if `_importGlobMap` (vite internal) exists before using it ([612d66f](vuejs/vitepress@612d66f))

#### [1.3.3](vuejs/vitepress@v1.3.2...v1.3.3) (2024-08-17)

##### Miscellaneous

-   bump deps ([a20db24](vuejs/vitepress@a20db24))

#### [1.3.2](vuejs/vitepress@v1.3.1...v1.3.2) (2024-08-05)

##### Bug Fixes

-   multiple cache busting imports causing useData to fail ([2b3e486](vuejs/vitepress@2b3e486)), closes [#&#8203;3820](vuejs/vitepress#3820), reverts [#&#8203;3398](vuejs/vitepress#3398), reopens [#&#8203;3363](vuejs/vitepress#3363)
-   **theme:** excerpt style in LocalSearchBox ([#&#8203;4050](vuejs/vitepress#4050)) ([2bc0d39](vuejs/vitepress@2bc0d39))

#### [1.3.1](vuejs/vitepress@v1.3.0...v1.3.1) (2024-07-14)

##### Bug Fixes

-   don't reopen browser on restart when `vite.server.open` is specified ([6263db1](vuejs/vitepress@6263db1)), closes [#&#8203;4040](vuejs/vitepress#4040)
-   **theme/regression:** typo in component props resulting in nested titles not showing in navbar ([01d0d45](vuejs/vitepress@01d0d45)), closes [#&#8203;4042](vuejs/vitepress#4042)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbInJlbm92YXRlIl19-->

Reviewed-on: https://gitea.ocram85.com/arkanum/arkanum/pulls/130
Reviewed-by: OCram85 <marco.blessing@googlemail.com>
Co-authored-by: renovate-bot <renovate@ocram85.com>
Co-committed-by: renovate-bot <renovate@ocram85.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants