Skip to content

Retained-hidden linked-state edits are silently discarded while any async transition is in flight #83

Closed as not planned

Description

@Huxpro

Found by an adversarial audit of the #58 L0–L3 equivalence claims. Pre-existing — verified by executing the same repro against a copy of base 6079a6804, where it fails identically. Not #64 drift. Filed because it silently loses user input, and it reaches the DOM runtime, not just the universal/Lynx path.

Root cause

packages/octane/src/universal-core.ts:5214-5232:

const transition = universalTransitionBatchForUpdate();
...
if (transition === null && record.visibility === 'suspense-hidden' && parked !== undefined && parked.generation === committed.generation)

The retained-hidden fast path requires transition === null. With any async transition pending — anywhere in the app, unrelated to this component — the gate at :5218 fails and the edit falls through to stageUniversalTransitionUpdate at :5259. When the replacement source finally commits, the generation check at :5252 discards it.

No re-render, no error, no trace.

Consumer impact

A user typing into a useLinkedState-backed field while a Suspense boundary shows a fallback loses those keystrokes if any async transition is still in flight elsewhere — a concurrent startTransition(async () => …) navigation or filter is enough. The two conditions are independent, so the app author has no local reason to expect interference.

The audit also reports the equivalent DOM-runtime scenario is lossy and additionally leaves getValue() stale: the DOM shows draft:B while getValue() returns draft:A!, persisting across two further renders. So the third tuple member — which docs/differences-from-react.md documents as one of Octane's deliberate divergences — disagrees with what is on screen.

Attribution, established by head-vs-base differential

Rather than trusting a worktree run, the lens dropped git show 6079a6804:packages/octane/src/universal-core.ts into packages/octane/src/zz-probe-c3-base-core.ts (same directory depth, so its relative imports resolve) and ran the same 12 linked-state scenarios against both module instances in one process. Base fails identically:

× c3 repro ON BASE 6079a6804: keeps the edit when an unrelated async transition is pending
  -> expected 'draft:B' to be 'draft:B!'

Scenarios covered: ordinary useState alongside useLinkedState in one retained component; abandonment of the hidden source with both cells edited; a parked edit followed by a non-suspending render; generation bookkeeping across two consecutive retains.

Suggested direction

The transition === null condition at :5218 conflates "this update is transitional" with "any transition batch exists". A pending unrelated transition should not disqualify a retained-hidden linked-state edit from the parked path. If the coupling is deliberate, the discard at :5252 should at minimum not be silent.

Related

Verification performed

Executed with captured output, including the head-vs-base in-process differential above. I did not independently re-run this one; it rests on the finding agent's executed evidence plus the source reading. Adversarial refuter panel had not adjudicated at time of filing.

Activity

  1. added
    bug
    on Aug 18, 2026
  2. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Withdrawing this — the trigger is unreachable from the claimed source, the behaviour is test-pinned, and the polarity is inverted

    A dedicated reachability audit took this apart. Every load-bearing claim in the issue fails, and the one that survives points the other way.

    1. A keystroke cannot reach it

    The claim was "a user typing into a useLinkedState field loses keystrokes." It cannot: input is discrete, and discrete depth forces the urgent path (runtime.ts:993, universal-core.ts:4876). The mechanism is reachable only from a deferred setter — a debounce timer, a post-await continuation, a subscription callback, or an effect.

    Nor can the user see it happen: the retained-hidden subtree is display: none !important, so the field is off-screen for the entire window in which the discard occurs.

    The auditor built the most ordinary triggering app it could — a compiled .tsrx master-detail editor with a debounced autosaving title field, driven through a real createRoot DOM root with real click and input events. It typechecks (tsrx-tsc --noEmit exit 0, with an injected-error sanity control proving the checker read the file). Reaching the mechanism still required a debounce timer firing after the boundary hid.

    2. The polarity is inverted — my proposed fix causes data corruption

    The same end-to-end app, run both ways:

    S (autosave transition in flight — the "buggy" staged path):
        after clicking entry r2, #title = "Hiring loop"        <- r2's own title. CORRECT.
    
    S-CONTROL (byte-identical, autosave removed — the "correct" parked path):
        #title = "Quarterly plan v2"                            <- entry r1's trailing debounced
                                                                   edit leaked into r2's field,
                                                                   while the body reads "body of r2".
                                                                   CROSS-RECORD CORRUPTION.
    

    The generation check I blamed at :5252 is precisely the guard that stops an abandoned-source draft from being replayed, and it says so in its own comment (universal-core.ts:5245-5251): "An old lane may still carry its former base state; replace it with the newly committed value instead of replaying a draft that belonged to the abandoned source."

    3. It is intentional and test-pinned

    Two passing committed tests pin the discard as designed, both present on base:

    • packages/octane/tests/linked-state.test.ts:680 — it('discards an old transition before parking a new source behind Suspense')
    • packages/octane/tests/linked-state.test.ts:712 — it('discards an unfinished transition update when its source changes urgently')

    Suite is 25/25 green at HEAD. The entangling of a non-discrete update into the in-flight batch is also a documented deliberate approximation (runtime.ts:990-993: "AsyncContext is not available in the browser target, so post-await Action continuations share the one entangled in-flight batch").

    4. Pre-existing, with a provenance discriminator

    universalLinkedStateHook is byte-identical base→HEAD (192 lines, empty diff); the gate is a pure line shift from base :5269 to HEAD :5218. packages/octane/src/runtime.ts — which owns the DOM behaviour I called lossy — is untouched by the entire stack. The DOM gate blames to 87cce2f69, confirmed an ancestor of base. A base-worktree run reproduces identically, with a provenance discriminator proving base code actually executed.

    What survives, if anything

    At most a low-severity path-consistency question: useLinkedState resolves an edit against a retained-hidden parked draft differently depending on whether an unrelated async transition batch happens to be open — the parked fast path preserves it, the staged path drops it. Pre-existing, invisible to the user, and out of scope for an issue-58 stack audit.

    What went wrong on my side

    This is the fourth withdrawal in this audit and the first to hit all three failure modes at once: unreachable from the source I described (#72's shape), intentional and test-pinned (#73's shape), and polarity inverted so that my fix would cause harm (#82's shape). I filed it on an agent's in-process differential — which was sound for attribution and said nothing about reachability — and I flagged at the time that I had not re-run it. That caveat was the tell, again.

    I had this ranked first or second in the triage list I gave the maintainers. It should not have been on the list.

    Closing as not-planned.


    Generated by Claude Code

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

    agent-authoredbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions