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

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

bug: Repeated builds will result in incorrect cache #3363

rxliuli opened this issue Dec 20, 2023 · 2 comments · Fixed by #3398
Labels
bug: pending triage Maybe a bug, waiting for confirmation

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants