Skip to content

tanstack fast deploy: publish write-through to KV is opt-in and fails silently; delta merge can lose publishes #779

Open

Description

@igoramf

Summary

On tanstack sites with fast deploy on (DECO_FAST_DEPLOY=1 + DECO_KV binding), CMS publishes never reach production until the next code deploy. Two problems in the framework, both fixable there instead of in every site:

  1. The publish write-through to KV is opt-in and fails silently. handleDecofileReload (blocks-admin/src/admin/decofile.ts) only writes decofile:<deploymentId> / index:revision:<deploymentId> if the site called setupTanstackFastDeploy() at startup. Otherwise getFastDeployKV stays at its default () => null, writeSnapshotToKV returns false, and the handler answers 200 { kvWritten: false } with no log. Only the isolate that received the Studio POST updates; every other isolate and every cold start keeps the snapshot written at deploy time.
  2. Once enabled, a delta publish can drop an earlier publish (lost update). POST /.decofile is handled in tanstack/src/sdk/workerEntry.ts (~L2027) before ensureBlocksHydrated (~L2146) and maybePollRevision. The handler does applyDelta(loadBlocks(), delta) and writes the whole result to KV. The base is whatever the isolate has in memory: the bundled decofile on a cold isolate, or a copy up to POLL_INTERVAL_MS (10s) old on a warm one.
    • Publish A hits isolate X → KV = deployed + A.
    • Delta publish B hits cold isolate Y → KV = deployed + B. A is gone from production until the next deploy.
    • Two publishes within 10s on different isolates do the same.
    • Before (1) is fixed this can't happen, because only deploys write KV. So fixing (1) alone exposes (2) on every site that does it.

Versions checked: 7.81.5 source. setupTanstackFastDeploy is exported but never called automatically in every version sites use (7.64.3 → 7.84.0).

Evidence (montecarlo-tanstack, 2026-11-06)

  • Home publish bdbc9cc7 committed at 17:43 UTC; prod still served the old banner 20+ min later (x-cache-version = last code deploy 86a9ff74).
  • DECO_KV: index:live = 86a9ff74; decofile:86a9ff74 still contained the old value and not the new one; index:revision:86a9ff74 unchanged. So no poll delay: the write never happened.
  • src/setup.ts didn't call setupTanstackFastDeploy(). Site-side fix: deco-sites/montecarlo-tanstack#1262.

Blast radius

Tanstack sites in deco-sites with DECO_FAST_DEPLOY: "1" + DECO_KV, checked on the default branch:

  • Missing the call (affected): bagaggio, care, casaevideo, farmrio, granadobr, granadobr-teste, lebiscuit, oficina, phebo, storefront, igor (sandbox), montecarlo (until #1262).
  • Call present: zeedog, zeedog-ecuador, zeenow, miess-01.

Care / granadobr / phebo / oficina mention fast deploy in code, but only on the read side (onChange, DECO_KV.get).

Proposal

  1. Wire it automatically. Call setFastDeployKVGetter(getFastDeployKV) inside the tanstack worker entry/site setup, the same place that already decides isFastDeployEnabled, so it is on whenever fast deploy is on. Keep setupTanstackFastDeploy() as an idempotent no-op for existing callers.
  2. Never fail silently. When fast deploy is enabled and the write-through doesn't happen (no getter, no deployment id, kv.put throws), log an error and return non-2xx (or let Studio surface kvWritten: false) so the publish isn't reported as successful.
  3. Merge against KV, not memory. In the reload handler, before applyDelta, hydrate from decofile:<liveId> and check index:revision:<liveId> (await ensureBlocksHydrated, or read KV directly). Ideally write conditionally on the revision you read, retrying on mismatch, so concurrent publishes can't overwrite each other.
  4. Optionally note in the docs/templates that setupTanstackFastDeploy() is no longer needed.

How to verify

  • Publish a small change in Studio → index:revision:<liveId> changes within seconds and the content is served by other isolates and cold starts with no deploy.
  • Two delta publishes on different blocks within a few seconds → both are present in decofile:<liveId>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions