`Slot` throws when a lazy child resolves to another lazy child (regression left over from #3165 / #3680, likely also #4082)
Bug report
Current Behavior
Slot (and Slottable) throws Slot failed to slot onto its `Slottable`. Expected `Slottable` to receive a single React element child. (or, without Slottable, Slot failed to slot onto its children. Expected a single React element child or `Slottable`.) when the asChild child is a React Flight "lazy" reference whose resolved value is itself another lazy reference — a real shape, not a contrived one: a Server Component's child crosses the Flight boundary as a lazy chunk, and that chunk can resolve to a reference to another chunk, e.g. when the resolved element's own subtree still has unresolved dependencies.
The fix in #3680 (8961a25) added isLazyComponent(children) && use(children._payload), but only unwraps one level. When the resolved value is itself lazy, the second layer is never unwrapped and Slot throws.
Expected behavior
Slot/Slottable should keep unwrapping lazy references until it reaches a real element, not stop after one layer.
Reproducible example
No StackBlitz needed — reproduces with the same deps slot.test.tsx already uses (react, react-dom, @testing-library/react). Drop this next to it:
/**
* Minimal reproduction for #3165. Follow-up to #3680 / 8961a25, which unwraps a React Flight
* "lazy" child via `use()` but only one level — a chunk resolving to a reference to another chunk
* isn't handled. No Next.js/RSC/Flight runtime needed: nesting one hand-built lazy wrapper inside
* another reproduces it, since the bug is in `Slot`'s unwrap logic, not in how the value got there.
*/
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import { Slot, Slottable } from "@radix-ui/react-slot";
const REACT_LAZY_TYPE = Symbol.for("react.lazy");
/** The real shape React Flight uses for an unresolved (or resolved-to-another-chunk) child. */
function flightLazy(value: React.ReactNode): React.ReactNode {
const payload = {
status: "fulfilled",
value,
reason: null,
then(resolve: (value: React.ReactNode) => void) {
resolve(value);
},
};
return { $$typeof: REACT_LAZY_TYPE, _payload: payload, _init: () => payload.value } as never;
}
afterEach(cleanup);
describe("Slot given a lazy chunk that resolves to another lazy chunk", () => {
it("renders a single level of nesting fine", () => {
render(<Slot>{flightLazy(<a href="/resolved">Click</a>)}</Slot>);
expect(screen.getByRole("link")).toHaveAttribute("href", "/resolved");
});
it("throws on a second level of nesting, as bare children", () => {
expect(() =>
render(<Slot>{flightLazy(flightLazy(<a href="/resolved">Click</a>))}</Slot>)
).toThrow(/Slot failed to slot onto its children/);
});
it("throws on a second level of nesting, inside `Slottable` alongside a sibling (Slot's own documented multi-child pattern)", () => {
expect(() =>
render(
<Slot>
<span data-decoration />
<Slottable>{flightLazy(flightLazy(<a href="/resolved">Click</a>))}</Slottable>
</Slot>
)
).toThrow(/Slot failed to slot onto its `Slottable`/);
});
});Test 1 (single-level nesting) passes today. Tests 2 and 3 (nested lazy) fail on current main/1.3.3/1.4.0-rc.* with the errors quoted above.
Suggested solution
Replace the single if (isLazyComponent(x)) x = use(x._payload) checks with a loop that unwraps until the value is no longer lazy-shaped, applied everywhere such a value is read before React.isValidElement — Slot's own top-level children, and whatever is pulled out of a matched Slottable (both the plain-children and render-prop child variants).
Additional context
getSlottableElementFromSlottable's render-prop child branch re-reads slottable.props.child directly instead of using the value the caller already unwrapped, so even one level of laziness on that variant bypasses the #3680 fix entirely.
This is likely the same issue as #4082, closed as not reproducible on a trivial single-Link example — consistent with test 1 above passing fine. The reporter's own follow-up there (Button asChild wrapping a Link + icon, only failing after several quick reloads, fixed by removing asChild) matches a child complex/slow enough to occasionally produce the double-wrapped shape reproduced deterministically here.
Your environment
| Software | Name(s) | Version |
|---|---|---|
| Radix Package(s) | @radix-ui/react-slot | 1.3.3 (also reproduces on 1.4.0-rc.1785512840124) |
| React | n/a | 19.2.8 |
| Browser | Chrome | n/a |
| Assistive tech | - | - |
| Node | n/a | v24.7.0 |
| npm/yarn/pnpm | bun | 1.4.2 |
| Operating System | macOS | 26.2 (Darwin 25.2.0, arm64) |
Source: radix-ui/primitives