You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Direct portal lowering drops eager arguments on the server and reorders them on the client #2592
The production DOM compiler gives these calls different observable behavior. Both use the genuine named Octane export. The target function returns an element on the client and the supported string 'body' on the server.
import { createPortal } from 'octane';
export function Direct({ mark, target }) @{
<main>{createPortal(mark('body'), target(), mark('key'))}</main>
}
export function Value({ mark, target }) @{
const result = createPortal(mark('body'), target(), mark('key'));
<main>{result}</main>
}
Let mark(name) record and return its argument, and target() record 'target' before returning. With a fresh component instance for each case:
Direct host child
Local value
Production renderToString
no calls
body, target, key
Production createRoot().render
target, body, key
body, target, key
With the literal target 'body', server-side Direct still drops both mark calls. If mark('body') throws, Value propagates the error and Direct emits a placeholder. On the client, a throwing first argument in Direct runs after an effectful target; the same exception stops the ordinary call before its target is evaluated.
The direct optimization should evaluate ordinary JavaScript argument expressions in source order. Server output can still be an empty placeholder, without resolving the target against a document or invoking a function supplied as the portal body. The same target/key controls with an inline JSX body and with a template thunk left the body's title expression deferred on both expression paths.
Activity