Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 6, 2025

Link to Devin run: https://app.devin.ai/sessions/97c785c20bfd40f592b8d50a107c09db
Requested by: kenny@buildwithfern.com

Short description of the changes made

Removes the prefetched.files optimization in createCachedDocsLoaderImpl.getFiles() and always calls getFiles(config)(domainKey) directly.

What was the motivation & context behind this PR?

Since Tuesday Dec 3, we've been seeing mdx_unresolved_file_ids errors where file: IDs in markdown don't match available files in filesV2. The previous revert (#5706) removed loadDocsBranch/loadDocsResponse but did NOT remove the prefetchPromise optimization.

Root cause: batchGetCommonMetadata reads directly from KV via kvMget and does NOT respect revalidateTag cache invalidation. When loader.getFiles() was called, it returned prefetched.files if non-null, bypassing the getFiles function which has unstable_cacheTag(domainKey, "getFiles"). This caused stale file data to be served after revalidation.

By always calling getFiles() which has unstable_cacheTag, we ensure file resolution respects revalidateTag invalidation.

How has this PR been tested?

  • Lint passes
  • This is a targeted fix that only changes the getFiles path; other prefetch optimizations (metadata, config, root, etc.) remain intact
  • Will need production verification to confirm the mdx_unresolved_file_ids errors stop occurring

Human review checklist

  • Verify the analysis is correct - that batchGetCommonMetadata doesn't respect revalidateTag
  • Consider if there are performance implications (note: getFiles() has its own caching via unstable_cacheTag)
  • Monitor PostHog after deployment to confirm mdx_unresolved_file_ids errors stop

The batchGetCommonMetadata prefetch reads directly from KV and does not
respect revalidateTag cache invalidation. This caused stale file data
to be served after revalidation, resulting in mdx_unresolved_file_ids
errors where file: IDs in markdown didn't match available files.

By always calling getFiles() which has unstable_cacheTag, we ensure
file resolution respects revalidateTag invalidation.

Co-Authored-By: kenny@buildwithfern.com <kenny@buildwithfern.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Contributor

vercel bot commented Dec 6, 2025

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

Project Deployment Preview Updated (UTC)
dev.ferndocs.com Ready Ready Preview Dec 6, 2025 4:02pm
fern-dashboard Ready Ready Preview Dec 6, 2025 4:02pm
fern-dashboard-dev Ready Ready Preview Dec 6, 2025 4:02pm
prod-assets.ferndocs.com Ready Ready Preview Dec 6, 2025 4:02pm
prod.ferndocs.com Ready Ready Preview Dec 6, 2025 4:02pm
1 Skipped Deployment
Project Deployment Preview Updated (UTC)
fern-platform Ignored Ignored Dec 6, 2025 4:02pm

@kennyderek kennyderek merged commit 60c238c into app Dec 6, 2025
20 checks passed
@kennyderek kennyderek deleted the devin/1765036365-fix-prefetched-files branch December 6, 2025 16:02
tsbhangu pushed a commit that referenced this pull request Dec 8, 2025
#5709)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: kenny@buildwithfern.com <kenny@buildwithfern.com>
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.

2 participants