Repository navigation
Live holes: a pending attribute inside a Loading boundary writes data-lha twice, and the element's later attr updates are dropped #4032
Description
On next (4937f0a), an element inside a <Loading> whose attribute reads a pending value is rendered with two data-lha addresses:
<template id="01"><ul data-lha="1" data-lha="0" data-l="r:0"><li>x</li></ul></template>Only lha:1 is bound. The stale data-lha="0" is also copied into every later attr op for that element:
type:"attr", key:"1", attrs:" data-lha=\"0\" data-l=\"r:1\""
What breaks
- First paint is fine. HTML parsers keep the first duplicate attribute,
data-lha="1", which is the bound one. - Attr updates stop after the first. In jsdom, the first op (key
"1") applies and its attr text rewrites the element todata-lha="0". The next op for key"1"finds no element, returnsapplied: false("pending; later flushes retry") and never lands. The attribute is stuck at its second value. - The markup is also invalid HTML (a duplicate-attribute parse error), though browsers recover.
Minimal repro
This uses the same imports and collect() helper as packages/web/test/server/document-live-holes.spec.tsx:
const S = () => {
const ready = createMemo(async () => (await wait(5), "r"));
const tick = createMemo(async function* () { yield 0; await wait(20); yield 1; });
const label = createMemo(() => ready() + ":" + tick());
return <Loading fallback={<span>FB</span>}><ul data-l={label()}><li>x</li></ul></Loading>;
};
const html = await collect(() => (frameTransformDirectResult(S, { id: "r/H3" }) as any)({}));The existing case in that spec, <ul data-ready={String(ready())}> inside <Loading> (around line 310), already produces <ul data-lha="1" data-lha="0" data-ready="true">. Its assertions don't look at the address.
Which variants duplicate
| Case | Result |
|---|---|
Pending attr inside <Loading> |
data-lha="1" data-lha="0" |
Pending attrs on both <ul> and <li> |
Both duplicated (2,0 and 3,1) |
Pending attr in a component inside .map inside <Loading> |
2,0 |
| Waterfall (attr reads a memo that reads a pending memo) | 1,0 |
| Attr reads an iterable whose first yield is delayed | Duplicated, and the stale address is in the op |
Resolved attr inside <Loading> with a pending sibling text |
Single 0 |
Pending attr with no <Loading> |
Single 0 |
| Sync attr then pending attr on the same element | Single 0 |
| Pending attr plus an iterable attr with a sync first yield, same element | Single, clean ops |
Re-evaluation sweeps never mint an address (live.sweeping gates it), so a sweep never duplicates.
Cause
Traced in the code and matched by the test output:
ssr()callscaptureStart()(packages/web/src/server.ts, around line 4176). It mints an id, splicesdata-lha="N"in right after the tag name, and setscap.baseto everything after the splice.- When that in-tag hole escalates (NotReady), the code sets
cap = nullbut leaves the spliced text in the template segment. That id is orphaned. - The
<Loading>resume callsctx.ssr(pending.t, ...pending.h)(packages/solid/src/server/hydration.ts:671; the same pattern is aroundsignals.ts:3635) on the segment that still holds the orphan. The tag is still open there, socaptureStart()mints again at the same offset. The new id goes first and the old one is pushed to the right. - The new capture's prefix now contains the stale
data-lha="0", socap.baseand every attr text rebuilt by a sweep carry it. - On the client,
#applyAttrs(packages/web/frames/src/frame-client.ts, around line 2198) skipsdata-lhaonly in its removal loop. Its set loop applies thedata-lha="0"from the op text, which moves the element off its bound address.
Not confirmed: why the last variant in the table avoids the duplicate. It probably goes through <Loading>'s discovery loop, which re-renders the children from scratch, instead of through the resume path.
Possible fixes (untried)
- Remove the spliced address when a capture is dropped on escalation, at all three
cap = nullsites. This also stops orphan ids in the cases that don't duplicate. - Or, in
captureStart, replace an existingdata-lha="…"at that offset instead of inserting a second one. - As a defence, have the set loop in
#applyAttrsskipdata-lha, as the removal loop already does.
Activity
[-]Live holes: a pending attribute inside `<Loading>` writes `data-lha` twice, and the element's second and later attr updates are dropped[/-][+]Live holes: a pending attribute inside a Loading boundary writes data-lha twice, and the element's later attr updates are dropped[/+]fix(web): drop a live attr capture's address when its tag escalates (#…
ryansolid commentedon Oct 14, 2026
Generated by Claude Code