Skip to content

Direct portal lowering drops eager arguments on the server and reorders them on the client #2592

Closed

Description

@domgan-oai

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.

Reproduced on e54671d and f9fcd74. The named binding reproduces independently of the shadowed-import fix in #2587. The documented literal-body contract is in differences from React. See server placeholder lowering and client portal lowering.

Codex task · Host com-79386

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions