Repository navigation
fix(lynx): validate cross-realm messages and accept a null event target id on Lynx for Web - #459
Conversation
… on Lynx for Web The two Lynx threads are separate JS realms in production (on Lynx for Web the background is its own iframe/worker), so a message main receives is a plain object carrying the sender realm's Object.prototype, never identical to main's. The plain-object validators used a realm-local `=== Object.prototype` identity test and rejected every background message: the readiness handshake never completed, so nothing committed — engine-mode first screen was blank and every tap was dropped. A shared hasCrossRealmPlainPrototype predicate accepts a null prototype or one that is itself one hop from null, across the protocol, host driver, host props, lifecycle data, worklet, and main-thread validators. A vm-based test reproduces the real second realm the single-realm jsdom suite could not.
@lynx-js/web-core reports an element with no author id as target.id === null. The native event payload snapshot required a string id and threw, dropping every tap. Accept null and normalize an omitted undefined id to null, keeping "no id" distinct from an author-assigned empty-string id and matching the PAPI's __SetID(node, id: string | null).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 0662825. Configure here.
|
|
||
| export interface LynxNativeEventTargetSnapshot extends LynxNativeEventPayloadRecord { | ||
| readonly id: string; | ||
| readonly id: string | null; |
There was a problem hiding this comment.
Public event id type stale
Medium Severity
The snapshot and runtime now preserve a missing target id as null, but the public LynxEventTarget.id in native-types.ts still types it as string. Background bind* handlers therefore type-check as always receiving a string while Lynx for Web can deliver null, so null-unsafe uses of event.target.id slip past typecheck and can throw at runtime.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0662825. Configure here.
…ane#459 Octane's every click-driven metric was previously unmeasurable on Lynx for Web. Root cause, found from here and fixed upstream: the two Lynx threads are separate JS realms on web (background runs in an iframe), and Octane's message validators used a realm-local `getPrototypeOf(v) === Object.prototype` check, so main rejected every message the background sent. The readiness handshake never completed and the background never committed. Measured against octanejs/octane#459 (not yet merged — re-take if review changes it). Storms n=3 × 1k/10k/30k with the four Vue comparators in one same-host session; mount-create ladder rebuilt at all six rungs, n=7; startup n=11. The penalty turns out to be shape-dependent, not the flat factor the earlier partial data suggested. Ratios vs `vdom`: select@10k 13.1x update10th@10k 10.0x (point updates) create@10k 2.05x mount-create ~1.8x flat updateStorm@30k 0.86x (batch: faster than vdom) Per-node object commands through structured clone re-ship whole-node commands for every update, with no equivalent of the tiny op payload the Vue cells collapse a point update into; under batch load that cost amortizes and Octane wins. Retraction: this branch previously reported Octane at the front of the startup column. That was an artifact of the bug — the background never committed, so Octane was timed doing strictly less work. With the handshake completing it is now the slowest cell (108.7 ms vs vdom+ifr 81.8). The earlier mount-create figures likewise measured main-thread-only paint and are superseded. - synthesize.mjs / report-unified.mjs: ingest cross-storms-octane-web.json - report-unified.mjs: NO_EVENT_ARCHS emptied (mechanism kept for any future undriveable framework), octane chart colour - report-i18n.mjs: conclusion cards rewritten around point-vs-batch; the first-screen note now explains the realm bug and flags the superseded numbers - OCTANE.md rewritten; UNIFIED.md + docs (EN/ZH) updated Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012PRZ3ps5MRQ9m75Wpx2f1h
…the bespoke workload Octane had a measurement path of its own — a `first-screen` workload with `--startup-only` / `--mount-create` runners, BENCH_AUTOROWS build variants, its own report section and two charts. That existed only because Octane could not be driven on Lynx for Web. octanejs/octane#459 removed that constraint, so the scaffolding is removed too and Octane is now an ordinary cell measured by the same two instruments as everything else. Removed (reverted to the base branch byte-for-byte where possible): - cross.mjs, build-unified.mjs, shared/data.ts, apps/ui-vdom, apps/ui-vapor — `--startup-only`, `--mount-create`, `--mount-reps`, BENCH_AUTOROWS, buildDataSeeded, __BENCH_AUTOROWS__ - synthesize.mjs: the `first-screen` workload - report-unified.mjs: the First screen section, both bespoke charts, the `yUnit` axis plumbing, the extra Coverage column, NO_EVENT_ARCHS - results/{startup-only,mount-create}.json Added — FCP, through the canonical runner: - core/workloads/content-octane.mjs — same feed + N keyed cards, same classes, same 4 + 8N element accounting as content.mjs and content-react.mjs - core/matrix.mjs: an `octane` cell - unified-content.mjs: buildOctaneContentRung, beside the ReactLynx branch - synthesize/report: octane in UNIFIED_ARCH_BY_CELL and FCP_ARCH_KEYS (A first attempt built this under packages/ifr-bench/ — the path unified-content.mjs explicitly supersedes, whose output the authoritative ingest would have overwritten. Deleted, not shipped.) Added — harness/verify-coverage.mjs, generic: walks latest.json against the coordinate lists the report renders and prints per-architecture what is missing, because an em-dash means both "not applicable" and "never measured". It reports `octane: COMPLETE` (11/11 storm ops, 6/6 FCP x1, 4/4 x4), and surfaces one pre-existing gap: vapor-ifr-code-paint is FCP-only, so its entire storm column is em-dashes today. FCP (x1, ms, octane / vdom): 179/130 1k · 285/205 3k · 437/281 5k · 679/456 10k · 1246/846 20k · 1590/1292 30k — 1.37x at 1k narrowing to 1.23x at 30k. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012PRZ3ps5MRQ9m75Wpx2f1h


Closes #460, #461, #462.
Summary
@lynx-js/web-core), where the two Lynx threads are separate JS realms (the background is its own iframe/worker).Why
The two Lynx threads are distinct realms in production. Every message, host-prop bag, worklet capture, and lifecycle record a thread receives is therefore a plain object carrying the sender realm's
Object.prototype, never identical to the receiver's. Octane's plain-object validators testedObject.getPrototypeOf(value) === Object.prototype— a realm-local identity check — so main rejected every message the background sent, starting withmain-ready-request("must be a plain object"). The handshake never completed, so the background never committed:firstScreenRender: 'engine'painted a blank screen (nothing released the deferred first screen, becausehandleReadynever ran), andThe single-realm jsdom suite could never observe this, because both "threads" share one realm there — which is also why it survived a green suite.
Separately,
@lynx-js/web-corereports an element with no author id astarget.id === null; the native event payload snapshot required a string id and threw, so once the handshake was fixed a tap still died in the validator.Changes
packages/lynx/src/core/plain-object.ts(new):hasCrossRealmPlainPrototype— accepts a null prototype or any prototype itself one hop from null (the shape of every realm'sObject.prototype), rejecting deeper chains. Descriptor walks still enforce enumerable, non-accessor, symbol-free data.protocol.ts(record),host-driver.ts(host props),host-props.ts(style + CSS scope),lifecycle-data.ts,worklets.ts,main-thread.ts(lifecycle record).native-events.ts:LynxNativeEventTargetSnapshot.idwidened tostring | null; snapshot acceptsnulland normalizes an omittedundefinedid tonull.node:vmtest builds envelopes in a real second realm and proves both validators accept them (protocol.test.ts); a cross-realmstyle/CSS-scope test (host-props.test.ts); a null/undefined target-id test (native-events.test.ts);runtime-compatibility.test.tsgraph updated for the new leaf module.Validation
pnpm typecheckpnpm format:check(changed files viapnpm format:files:check)pnpm test packages/lynx— 267 passed, incl. the new cross-realm/id-null regressionsdemoexample through@lynx-js/web-core+<lynx-view>in Chromium via Playwright and drove a real mouse click. Before: engine modeelements rendered: 0; immediate mode painted butCount 0never advanced. After: renders 15 elements and the click moves Count 0 → Count 1 in both engine and immediate modes.pnpm test(ran the lynx project + full typecheck; did not run every project)The vm-based regression is the pre-fix oracle (verified it fails on the old
=== Object.prototypecheck with the exact production error).Risk / follow-ups
@lynx-js/web-coreand drives one real click — every one of these bugs survived a green suite because the existing event tests calldispatchNativeEventdirectly, bypassing the engine, handshake, and validator. A self-contained Playwright harness exists and can be contributed if wanted.Provenance
agent-authored)Note
Medium Risk
Touches core thread-boundary validation and slightly relaxes plain-object checks (one-hop-from-null prototypes); mitigated by existing descriptor walks and focused vm regressions, but incorrect acceptance could affect security-sensitive message handling.
Overview
Fixes Lynx for Web where background and main run in separate JS realms (iframe/worker), so cross-thread plain objects no longer fail realm-local
Object.prototypeidentity checks.Introduces
hasCrossRealmPlainPrototypeinplain-object.tsand wires it into every validator that sees background-originated data: transportprotocol,host-driverhost-prop cloning,host-propsstyle/CSS scope,lifecycle-data,worklets, andmain-threadlifecycle records. Descriptor walks for enumerable, non-accessor data stay unchanged; only the “plain shape” test is realm-safe.native-eventswidens event targetidtostring | null, acceptsnullfrom@lynx-js/web-core, and normalizes omittedundefinedtonull.Adds
node:vmregressions for cross-realm protocol envelopes and host props, plus null/undefined target-id snapshots; updates the runtime-compatibility module graph for the new leaf.Reviewed by Cursor Bugbot for commit 0662825. Bugbot is set up for automated code reviews on this repo. Configure here.