Skip to content

Treat LiteFS helpers as local when disabled#804

Merged
kody-bot merged 2 commits into
mainfrom
cursor/blog-cache-ttl-hotfix-880b
Jun 14, 2026
Merged

Treat LiteFS helpers as local when disabled#804
kody-bot merged 2 commits into
mainfrom
cursor/blog-cache-ttl-hotfix-880b

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Treat litefs-js wrapper calls as local no-ops unless LITEFS_ENABLED=true.
  • Prevent disabled-LiteFS deployments from reading .primary, emitting Fly replay headers, waiting on tx-number files, or replaying requests to a primary instance that no longer exists.

Testing

  • npm --workspace kentcdodds.com run typecheck passed.
  • npm --workspace kentcdodds.com run test:backend passed.
  • Local production smoke on PORT=4300, MOCKS=true, LITEFS_ENABLED=false returned /healthcheck in ~1ms and /build/info.json with X-Fly-Primary-Instance: local-no-litefs.
  • Normal git push pre-push hook remains blocked by missing Playwright Chromium in this Cloud VM; pushed with HUSKY=0 after explicit focused checks.
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added configurable LiteFS functionality with environment variable toggle for flexible multi-instance behavior and consistency handling.
  • Chores

    • Optimized cache expiration timing for blog list items with dedicated TTL settings.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f74b154-81cd-44ff-8d9a-07737454b32b

📥 Commits

Reviewing files that changed from the base of the PR and between 2f1915e and 6ea006d.

📒 Files selected for processing (2)
  • services/site/app/utils/litefs-js.server.ts
  • services/site/app/utils/mdx.server.ts

📝 Walkthrough

Walkthrough

litefs-js.server.ts replaces flat re-exports with wrapper functions gated on process.env.LITEFS_ENABLED === 'true'; when disabled, each function returns a safe local default instead of calling the LiteFS library. mdx.server.ts adds a blogListTTL constant and uses it as the default TTL for getBlogMdxListItems.

Changes

LiteFS conditional wrapper layer

Layer / File(s) Summary
LITEFS_ENABLED guard and local instance helper
services/site/app/utils/litefs-js.server.ts
Adds isLitefsEnabled() (checks LITEFS_ENABLED env var) and getLocalInstanceInfo() (derives a primary instance record from FLY_MACHINE_ID or os.hostname()). These two helpers underpin all conditional wrappers.
Instance info and TX number wrappers
services/site/app/utils/litefs-js.server.ts
getInstanceInfo, getInstanceInfoSync, waitForUpToDateTxNumber, getTxNumber, getTxSetCookieHeader, getInternalInstanceDomain, and getAllInstances are each replaced with wrappers that return local/static defaults when LiteFS is disabled and delegate to litefs-js otherwise.
Remix transactional consistency no-ops
services/site/app/utils/litefs-js.server.ts
checkCookieForTransactionalConsistency, ensurePrimary, ensureInstance, handleTransactionalConsistency, and appendTxNumberCookie return { type: 'ok' }, true, or undefined when LiteFS is disabled; getReplayResponse remains an unconditional pass-through.

Blog list MDX cache TTL

Layer / File(s) Summary
blogListTTL constant and getBlogMdxListItems default
services/site/app/utils/mdx.server.ts
Adds a blogListTTL constant set to defaultStaleWhileRevalidate and uses it as the default ttl in getBlogMdxListItems, decoupling the blog list cache lifetime from defaultTTL.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • kentcdodds/kentcdodds.com#803: Directly related — also introduces blogListTTL and updates the default TTL in getBlogMdxListItems within mdx.server.ts.
  • kentcdodds/kentcdodds.com#791: Related — removes ensurePrimary call sites and adjusts LiteFS helper usage, which this PR complements by making those helpers no-ops when LiteFS is disabled.

Poem

🐇 Hop, hop, the LiteFS gate swings wide,
When LITEFS_ENABLED is false, we just glide—
A hostname for instance, a zero for TX,
No replay, no primary, no fuss to perplex.
The blog list now caches at its own gentle pace,
And the rabbit lands softly in a quieter place. 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/blog-cache-ttl-hotfix-880b

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cursor cursor Bot changed the base branch from cursor/fix-production-document-hang-880b to main June 14, 2026 14:57
@kody-bot kody-bot marked this pull request as ready for review June 14, 2026 15:02
@kody-bot kody-bot merged commit edcd8f7 into main Jun 14, 2026
9 of 10 checks passed
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.

3 participants