Repository navigation
Description
client: delayed form hydration removes a newly received form
Summary
A delayed session-form list response can overwrite a newer form.created event in createData. A form present in the real client cache disappears when the older empty snapshot commits.
This is specifically the form-cache hydration path. Permission hydration is already tracked by the open, unmerged PR #52074 and is not a new issue in this report.
Environment
- Windows build 22631; Bun 1.4.2.
- Executed checkout: custom fork at
72d0dce8ea437ea061e0680110fa19a81aa118fd, client package 2.0.32. - Source comparison: the affected behavior also exists at official
63c1a27af5a391d9caa55b82694f496911e1859b. Comparison with dev60a5a6cfound only three AI-file changes and no client changes. Those official revisions were not dynamically tested. - Headless Bun test with
--conditions=browser; realcreateDataand Promise client, injected in-memory fetch, no plugins or real service involved.
Reproduction
Use the local deferred-fetch/listener fixture pattern from packages/client/test/solid-inbox-race.test.ts:15-35 in a scratch test. It constructs a real createData with an injected Promise-client fetch and an event-listener set; it does not replace the reducer. The helper is not exported, so do not import the test file itself.
Create an existing remembered session and this form:
const form = {
id: "frm_hydration_audit",
sessionID,
title: "Fixture question",
metadata: { kind: "question" },
fields: [{ type: "string", key: "answer", title: "Answer", required: true }],
}Then use this ordering:
- Call
data.session.form.sync(sessionID). - In the injected fetch, wait until
GET /api/session/:sessionID/formarrives, then hold its old empty response withPromise.withResolvers<Response>(). - Emit a complete
form.createdevent through the fixture listener, with a unique event ID,created,location: { directory: "/project" }, anddata: { form }. - Confirm
data.session.form.list(sessionID)containsfrm_hydration_audit. - Resolve the held response with
Response.json({ data: [] })and await the original sync. - Read
data.session.form.list(sessionID)again. The expected assertion that the form remains present fails.
Control: resolve and await the same empty list response before emitting form.created. The form then remains in the cache. This non-interleaved control passed, validating both hydration and event delivery.
Expected Behavior
A snapshot taken before form.created must not erase that newer form from the client projection. Initial hydration and live form events must converge without requiring an unrelated disconnect.
Actual Behavior
| Checkpoint | Form IDs in the real client cache |
|---|---|
After form.created, before releasing HTTP |
["frm_hydration_audit"] |
| After the old empty HTTP response commits | [] |
The interleaved case used one form GET, with no fixture errors. The non-interleaved control retains the same form. No extra sync was added to repair the observation.
Additional Context
Source references below use checkout 72d0dce:
packages/client/src/solid/data.ts:1288-1293:form.createdappends the new form.packages/client/src/solid/data.ts:1841-1861: form hydration publishes its response without reconciling form events received during the read. This reproduction exercises the session-owned branch at line 1860, not global forms.packages/client/src/solid/data.ts:1220-1223: replied/cancelled forms also have live removal handlers, which should be considered when defining the hydration reconciliation semantics; no separate form-resurrection result is claimed here.- Official
63c1a27has the session-form replacement atpackages/client/src/solid/data.ts:1850.
Related: PR #52074. Its patch adds permissionUpdates for permission hydration, but does not add corresponding form-update reconciliation. This draft reports the independently owned form path only; it does not reopen permission hydration as a new issue.
The experiment confirms loss from the client projection. It did not run a rendered form dock or a real server execution, so a real execution stall is not claimed as measured. Subsequent reconnect/revalidation behavior and production frequency were not tested.
Suggested solution — not implemented
Reconcile form.created and settlement events with in-flight form-list hydration at the data owner, or use a consistent read/version boundary with a bounded revalidation path. Reuse the event-precedence approach already present for inbox/activity, and the related permission work where appropriate. Preserve successful initial hydration: dropping or aborting every overlapping read alone can leave the cache unhydrated. No additional synchronization framework is needed for this proposal.
Activity
opencode-agent commentedon Oct 18, 2026
Thanks for the detailed report. I reproduced this on the latest
dev(60a5a6c); the client form code is the same there as in v2.0.32.The script below is a headless Bun test that uses the real
createDataand Promise client with an injected fetch:data.session.form.sync(sessionID)and hold theGET /api/session/:id/formresponse.form.createdforfrm_hydration_audit.form.list(sessionID)now shows["frm_hydration_audit"].{ data: [] }response.form.list(sessionID)becomes[].The control case passes: when the empty response arrives before
form.created, the form stays. The session branch ofsession.form.syncreplaces the cached list with the response and doesn't merge in form events received during the read.Related:
Reproduction script (form-hydration-race.repro.test.ts)
Run it:
bun form-hydration-race.repro.test.tsfix(client): keep live form events during form list refresh
vladyslavarkavenko commentedon Oct 18, 2026
I opened #56876 for this. It records form events while the session form list is loading and applies them to the response, the same way inbox hydration already works. The tests cover a form created during the read, and a form replied to or cancelled during the read.