Repository navigation
fix(lynx): unwrap native event element references in worklet arguments - #395
Merged
trueadm merged 1 commit intoJul 29, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
trueadm
approved these changes
Jul 29, 2026
This was referenced Jul 30, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ elementRefptr }target wrappers to the raw main-thread element instead of rejecting the whole event.Why
target/currentTargetare{ elementRefptr: <element> }wrappers (the pinned ReactLynx envelope; its worklet runtime converts them toElementinstances). Octane's strict data-only argument isolation rejected the wrapper, so everymain-thread:bind*handler threw on device:TypeError: Octane Lynx worklet arguments[0].currentTarget.elementRefptr: contains a non-clone-safe value.(Lynx Explorer 3.9, iOS). The JavaScript testing environment never dispatches this envelope, so host tests could not see it.Elementwrapper is the raw PAPI node — the same value amain-thread:refcell holds — so the unwrap converges both element surfaces.Changes
worklets.ts:CloneStategains anunwrapElementReferencesmode used by a newisolateLynxWorkletArguments(); the worklet registry'sexecuteisolates arguments through it. Wrappers unwrap by identity (registered in the clone map so aliases stay aliases); a nullishelementRefptrstill fails validation. On PrimJS the element reference'stypeofis not necessarily'object', so only nullish is rejected.worklets-core.test.ts: regression asserting the worklet receives the raw element by identity for bothtargetandcurrentTargetwhile sibling event data is still isolated by copy.Validation
vitest run --project lynx— 260 tests passedtsgo --noEmit -p packages/lynx/tsconfig.jsonprettier --checkon changed filesmain-thread:bindscroll(Product Gallery scrollbar) andmain-thread:bindtouchstart/move/end(Product Detail swiper) execute per-frame on Lynx Explorer 3.9 (iOS) with this changeRisk / follow-ups
event.target; that matches the existingmain-thread:refcontract and ReactLynx's envelope semantics. No changeset:@octanejs/lynxis private.Note
Medium Risk
Changes the main-thread worklet argument isolation contract so handlers can observe live native elements via events; scope is limited to args that never leave the main thread.
Overview
Fixes main-thread bind handlers that threw on native Lynx because strict argument cloning rejected the pinned event envelope’s
{ elementRefptr }wrappers ontarget/currentTarget.cloneValuegains anunwrapElementReferencesmode (only for worklet args): those wrappers pass through as the raw main-thread element by identity (same asmain-thread:ref), with nullishelementRefptrstill failing validation.isolateLynxWorkletArguments()uses that mode; the main-thread registryexecutepath switches fromisolateLynxWorkletValuefor params. Captures, cross-thread calls, and other isolation boundaries stay data-only.Adds a regression test: worklet sees native element by identity for both targets while
detailremains copy-isolated.Reviewed by Cursor Bugbot for commit 290774d. Bugbot is set up for automated code reviews on this repo. Configure here.