Skip to content
Source
Sign inSign up
TanStack/db

docs: warn about isPersisted vs isPersisted.promise footgun #1322

ClosedDanny-Devs(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1322/headopened

Adds an IMPORTANT callout to the Transaction States section warning that await tx.isPersisted silently resolves immediately because Deferred is not a thenable. Users must use tx.isPersisted.promise.

This is a real-world bug we hit in production. TypeScript does not flag it because await accepts any. The consequence is that forms clear, navigation fires, and success messages display before the server confirms the write — and if the server rejects, the rollback happens silently with no error handling.

Context:

  • Deferred<T> (defined in src/deferred.ts) has no .then() method
  • await nonThenable resolves to the value itself per the JS spec
  • Every doc example already uses .promise correctly, but there's no explicit warning about omitting it
    1. ⚠️ No Changeset found

      Latest commit: 9e51a6ec0591f0a35ba1a7b4009454a8ceade5ab

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

Sign in to join this conversation.