Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 26, 2025

Fixes stale cache issue when fetching docs.yml content for the Editor.

Short description of the changes made

Modified getTree in github-loader.ts to resolve the branch ref to a commit SHA before caching. Previously, the tree was cached using the branch name (e.g., "main") as the cache key with no revalidation period, causing the cache to potentially live forever even as the branch moved forward.

Key changes:

  • Resolve ref to commit SHA via resolveRefToSha before making the GitHub API call
  • Use commit SHA in both the API request and cache key (making the cache immutable per commit)
  • Add github-repo-${owner}-${repo} tag to enable cache invalidation via invalidateRepoCache
  • Integrated with existing skipCache functionality from app branch

What was the motivation & context behind this PR?

The Editor was showing stale docs.yml content when creating new sessions. The root cause was that getTree cached the repository tree based on branch name with no revalidate period, so once cached, the tree data would never refresh even when new commits were pushed to the branch.

Now when the branch moves to a new commit, getCommitRef (with 5-min TTL) will return the new SHA, resulting in a new cache key for getTree and fresh tree data.

How has this PR been tested?

  • Code analysis and review of the caching flow
  • Lint checks passed
  • Dashboard dev server compiles and starts successfully

Human review checklist

  • Verify the error handling is appropriate - the function now throws if ref resolution fails (previously would have attempted the API call with the branch name)
  • Confirm the additional resolveRefToSha call overhead is acceptable (it's cached with 5-min TTL)
  • Consider if the 5-minute TTL on getCommitRef is acceptable for New Session freshness requirements
  • Verify skipCache functionality still works correctly with the new commit SHA-based caching

Link to Devin run: https://app.devin.ai/sessions/66976b7aab5a4c25b2b2278dd58217a2
Requested by: stephen@buildwithfern.com

…ead of branch name

Co-Authored-By: stephen@buildwithfern.com <stephen@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 Nov 26, 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 3, 2025 7:31pm
fern-dashboard Ready Ready Preview Dec 3, 2025 7:31pm
fern-dashboard-dev Ready Ready Preview Dec 3, 2025 7:31pm
prod-assets.ferndocs.com Ready Ready Preview Dec 3, 2025 7:31pm
prod.ferndocs.com Ready Ready Preview Dec 3, 2025 7:31pm
1 Skipped Deployment
Project Deployment Preview Updated (UTC)
fern-platform Ignored Ignored Dec 3, 2025 7:31pm

Co-Authored-By: stephen@buildwithfern.com <stephen@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.

1 participant