fix(cli): invalidate cached docs bundle when CLI version changes#15527
Open
thesandlord wants to merge 2 commits intomainfrom
Open
fix(cli): invalidate cached docs bundle when CLI version changes#15527thesandlord wants to merge 2 commits intomainfrom
thesandlord wants to merge 2 commits intomainfrom
Conversation
Previously, fern docs dev only checked the remote bundle's ETag to decide whether to use the cached bundle. After upgrading the CLI (fern upgrade), the old bundle in ~/.fern/app-preview could contain stale turbopack-hashed modules (e.g. qs-0df67fa3c19a2c11, gray-matter-7a5a01feddb85c93) that the new bundle expected at different paths. This caused 'Cannot find module' errors on Windows. Now the CLI version is stored alongside the ETag. When the version changes, the bundle is automatically re-downloaded and re-processed. Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Contributor
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
Two changes to fix stale docs preview bundles on Windows: 1. Replace rename+async-rm with synchronous rm before extraction. On Windows, rename can fail when NTFS junctions or locked files are present, leaving old files mixed with the new extraction. 2. Move the ETag write to after all post-processing (esbuild install, install-esbuild.js, instrumentation.js removal). Previously the ETag was written before these steps, so a failed post-processing would still cache the broken bundle. Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a Windows issue where
fern docs devshows "Cannot find module" errors (e.g.qs-0df67fa3c19a2c11,gray-matter-7a5a01feddb85c93,zod-a86475cb848a1e8f) due to stale files from a previous bundle surviving re-download.Two root causes:
Old bundle not fully removed: The old code used
rename+ async fire-and-forgetrmto clean the old bundle. On Windows,renamecan fail when NTFS junctions or locked files are present, leaving old files in place. The new bundle then extracts on top, creating a mix of old and new turbopack-hashed modules.ETag written before post-processing: The ETag was written immediately after decompression, before
pnpm i esbuild,install-esbuild.js, andinstrumentation.jsremoval. If any post-processing step failed, the ETag was already cached, so the next run would skip re-download and reuse the broken bundle.Changes Made
rename+ asyncrmwith synchronousawait rm(..., { recursive: true, force: true })to fully delete the old bundle before extracting the new onerenameimportTesting
Link to Devin session: https://app.devin.ai/sessions/1cd17ac93bd94ddc977642e06bcde56e
Requested by: @thesandlord