Skip to content

fix(packages/cli): disable persistent build cache on config-reload restart#67

Merged
zrosenbauer merged 2 commits intomainfrom
fix/config-reload-cache
Mar 24, 2026
Merged

fix(packages/cli): disable persistent build cache on config-reload restart#67
zrosenbauer merged 2 commits intomainfrom
fix/config-reload-cache

Conversation

@zrosenbauer
Copy link
Copy Markdown
Member

@zrosenbauer zrosenbauer commented Mar 24, 2026

Summary

  • Config changes to zpress.config.ts were not propagating to the dev server because Rspress's persistent build cache (buildCache.cacheDigest) only tracks sidebar/nav structure — it has no visibility into zpress-specific values like title, theme, colors, or source.define compile-time constants
  • On config-reload restarts, the persistent cache is now disabled (buildCache: false) so Rsbuild does a fresh compilation with the updated config
  • Initial cold starts still benefit from the persistent cache

Changes

  • packages/cli/src/lib/rspress.ts: Added isRestart parameter to startServer; added buildCacheOverride helper that returns { performance: { buildCache: false } } on restarts

Testing

  1. Run zpress dev in a project
  2. Change title, theme.name, or theme.colors in zpress.config.ts
  3. Verify terminal shows: "Config changed" → "Config reloaded" → "restarting dev server" → "Dev server restarted"
  4. Verify the browser reflects the new values after restart

Summary by CodeRabbit

  • Bug Fixes
    • Prevented stale output after config-reload restarts by bypassing the persistent build cache during restart so changes to title, theme, colors and similar config updates are applied.
    • Preserved the persistent build cache on initial startup to keep normal dev performance behavior.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oss-zpress Ready Ready Preview, Comment Mar 24, 2026 8:11pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: e2b85b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@zpress/cli Patch
@zpress/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

Walkthrough

Changed rspress.ts to add an internal StartServerOptions (skipBuildCache), update startServer to accept it, and apply a buildCacheOverride to disable the persistent build cache only for config-reload restarts while leaving initial startup cache enabled.

Changes

Cohort / File(s) Summary
Dev server start/restart
packages/cli/src/lib/rspress.ts
Added StartServerOptions with skipBuildCache; changed startServer(config, internalOptions) signature; added buildCacheOverride(internalOptions) and wired it into dev()'s extraBuilderConfig. Initial start calls with { skipBuildCache: false }, config-reload restarts call with { skipBuildCache: true }.
Release notes / changeset
.changeset/fix-config-reload-cache.md
New changeset documenting the patch that disables persistent build cache during config-reload restarts to avoid stale output from persistent cache.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI
    participant Rspress as Rspress (startServer)
    participant Builder as Builder (dev()/rsbuild)

    CLI->>Rspress: startServer(config, {skipBuildCache: false})  %% initial boot
    Rspress->>Builder: dev(extraBuilderConfig + buildCacheOverride(skip=false))
    Builder-->>Rspress: start up with persistent build cache
    Rspress-->>CLI: dev server ready

    CLI->>Rspress: startServer(newConfig, {skipBuildCache: true})  %% config-reload restart
    Rspress->>Builder: dev(extraBuilderConfig + buildCacheOverride(skip=true))
    Builder-->>Rspress: start up with buildCache disabled
    Rspress-->>CLI: restarted without persistent cache
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: disabling the persistent build cache specifically on config-reload restart to fix config propagation issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

…start

Rspress's persistent build cache (`buildCache.cacheDigest`) only tracks
sidebar/nav structure and the Rspress version. It is unaware of zpress-specific
config values (title, theme, colors, `source.define` compile-time constants).
When only those values changed, the stale cached build output was served,
making config changes appear to have no effect.

Additionally, `configFilePath: ''` meant the file-based `buildDependencies`
invalidation path was a no-op, so no config file change could bust the cache.

Disable the persistent build cache on config-reload restarts by passing
`performance: { buildCache: false }` via `extraBuilderConfig`. The initial
cold start still benefits from the cache; only restarts triggered by config
changes bypass it to force a fresh Rsbuild compilation.

Co-Authored-By: Claude <noreply@anthropic.com>
@zrosenbauer zrosenbauer force-pushed the fix/config-reload-cache branch from 5332ddd to 4ec07bd Compare March 24, 2026 19:09
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/lib/rspress.ts`:
- Around line 254-259: The function buildCacheOverride currently returns a loose
Record<string, unknown>; change its return type to a precise shape (e.g., an
object with an optional performance property containing an optional buildCache
boolean) so consumers and spreads into extraBuilderConfig get proper typing.
Update the signature of buildCacheOverride to return that specific
interface/inline type and ensure the two return paths return objects matching
that shape (performance?: { buildCache?: boolean }), which will improve IDE
assistance and catch typos when spreading into extraBuilderConfig.
- Line 69: Refactor the startServer function to accept a single object parameter
instead of two positional args: change the signature from startServer(config:
ZpressConfig, isRestart: boolean) to startServer({ config, isRestart }: {
config: ZpressConfig; isRestart?: boolean }): Promise<boolean> (keep the
explicit return type), update the implementation to use the destructured
properties, and update all call sites that invoke startServer(...) to pass an
object (e.g., startServer({ config, isRestart })) ensuring optionality/defaults
for isRestart are handled consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f9619fc2-6fa2-4a8e-ac32-7c7e967af545

📥 Commits

Reviewing files that changed from the base of the PR and between c808623 and 5332ddd.

📒 Files selected for processing (1)
  • packages/cli/src/lib/rspress.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/cli/src/lib/rspress.ts (1)

77-80: 🛠️ Refactor suggestion | 🟠 Major

Refactor startServer to a single object parameter.

Line 77 still uses two parameters. This violates the repo rule for 2+ args and makes callsites less self-describing.

♻️ Suggested refactor
-  async function startServer(
-    config: ZpressConfig,
-    internalOptions: StartServerOptions
-  ): Promise<boolean> {
+  async function startServer(options: {
+    readonly config: ZpressConfig
+    readonly internalOptions: StartServerOptions
+  }): Promise<boolean> {
+    const { config, internalOptions } = options
     const rspressConfig = createRspressConfig({
       config,
       paths,
       vscode: options.vscode,
       themeOverride: options.theme,
       colorModeOverride: options.colorMode,
     })
-  const started = await startServer(options.config, { skipBuildCache: false })
+  const started = await startServer({
+    config: options.config,
+    internalOptions: { skipBuildCache: false },
+  })
-    const restarted = await startServer(newConfig, { skipBuildCache: true })
+    const restarted = await startServer({
+      config: newConfig,
+      internalOptions: { skipBuildCache: true },
+    })

As per coding guidelines: "Use object parameters for functions with 2+ parameters and include explicit return types".

Also applies to: 114-114, 148-148

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/lib/rspress.ts` around lines 77 - 80, Refactor the
startServer function signature to accept a single object parameter instead of
two positional args: change it from startServer(config: ZpressConfig,
internalOptions: StartServerOptions): Promise<boolean> to startServer({ config,
internalOptions }: { config: ZpressConfig; internalOptions: StartServerOptions
}): Promise<boolean>, update the function body to use the destructured
properties, and keep the explicit Promise<boolean> return type; then update
every callsite that invokes startServer(...) to pass an object with properties
config and internalOptions (search for startServer usages mentioned in the
review), and ensure any related overloads/exports/imports continue to compile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/cli/src/lib/rspress.ts`:
- Around line 77-80: Refactor the startServer function signature to accept a
single object parameter instead of two positional args: change it from
startServer(config: ZpressConfig, internalOptions: StartServerOptions):
Promise<boolean> to startServer({ config, internalOptions }: { config:
ZpressConfig; internalOptions: StartServerOptions }): Promise<boolean>, update
the function body to use the destructured properties, and keep the explicit
Promise<boolean> return type; then update every callsite that invokes
startServer(...) to pass an object with properties config and internalOptions
(search for startServer usages mentioned in the review), and ensure any related
overloads/exports/imports continue to compile.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ba771c6a-93b0-4ea7-b8f8-d9d716878fa8

📥 Commits

Reviewing files that changed from the base of the PR and between 5332ddd and 4ec07bd.

📒 Files selected for processing (2)
  • .changeset/fix-config-reload-cache.md
  • packages/cli/src/lib/rspress.ts

@zrosenbauer zrosenbauer merged commit f88d0f7 into main Mar 24, 2026
5 checks passed
@zrosenbauer zrosenbauer deleted the fix/config-reload-cache branch March 24, 2026 20:20
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