Skip to content

fix(lynx): count only real symbols in wire-value validation (PrimJS compat) - #392

Merged
trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:fix/lynx-primjs-own-symbols
Jul 29, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:fix/lynx-primjs-own-symbols

Conversation

@Huxpro

@Huxpro Huxpro commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared hasOwnSymbolFields helper and use it at every "no symbol fields" wire-value validation site in @octanejs/lynx, so validation counts only real symbols.

Why

  • PrimJS (the Lynx production JS engine) violates the Object.getOwnPropertySymbols contract for arrays: it returns the integer index keys as strings (Object.getOwnPropertySymbols([7, 8]) → ["0", "1"], each typeof "string"). Verified on Lynx Explorer 3.9 (iOS) via CDP Runtime.evaluate.
  • Every Object.getOwnPropertySymbols(value).length !== 0 guard therefore false-positives on any array, and array-valued payloads are everywhere in the transport: on device, every main-thread event handler with captures failed with Octane Lynx thread captures: contains symbol fields. before this change. jsdom-based tests never see this because Node's engine is conformant.

Changes

  • New packages/lynx/src/core/own-symbols.ts with hasOwnSymbolFields(), which filters typeof key === 'symbol'.
  • Replaced the raw getOwnPropertySymbols(...).length !== 0 checks in worklets.ts, protocol.ts (2×), native-events.ts, nodes-ref.ts, lifecycle-data.ts, and main-thread.ts (2×).
  • worklets-core.test.ts: regression that emulates PrimJS's behavior via a getOwnPropertySymbols spy — array captures must pass, while a genuine symbol field must still be rejected.
  • runtime-compatibility.test.ts: the runtime source-graph inventory gains own-symbols.ts in both thread graphs.

Validation

  • vitest run --project lynx — 23 files, 260 tests passed
  • tsgo --noEmit -p packages/lynx/tsconfig.json
  • prettier --check on all changed files
  • device evidence: with this fix (plus the sibling PRs), main-thread:bindscroll/bindtap captures validate and run on Lynx Explorer 3.9 (iOS)
  • full repo pnpm test/pnpm typecheck not run for this PR in isolation

Risk / follow-ups

  • On conformant engines the helper is behavior-identical (it still rejects genuine symbol-keyed fields, covered by the new test). No changeset: @octanejs/lynx is a private package.

Note

Low Risk
Behavior on conformant engines is unchanged except for the PrimJS fix; scope is validation helpers and tests with no auth or data-model changes.

Overview
Fixes false “contains symbol fields” failures on Lynx device when payloads include arrays (e.g. main-thread event captures), caused by PrimJS returning array index keys from Object.getOwnPropertySymbols instead of only real symbols.

Adds shared hasOwnSymbolFields in own-symbols.ts (treats a key as a symbol only when typeof key === 'symbol') and swaps every Lynx wire-value / clone guard that used getOwnPropertySymbols(...).length !== 0 for that helper across lifecycle data, protocol, worklets, native events, nodes-ref, and main-thread tuple checks.

Adds a worklets regression test that mocks PrimJS’s getOwnPropertySymbols behavior (arrays pass, genuine symbol keys still fail) and updates the runtime source-graph inventory for the new module.

Reviewed by Cursor Bugbot for commit 786047d. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
octane-website Ready Ready Preview Jul 29, 2026 7:36pm
octane-website-mcp Ready Ready Preview Jul 29, 2026 7:36pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 29, 2026 19:35 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 29, 2026 19:36 Inactive
@trueadm
trueadm merged commit 95ad831 into octanejs:main Jul 29, 2026
18 of 28 checks passed

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 786047d8 Deployed Jul 29, 2026 by vercel[bot]
Preview – octane-website-mcp — 786047d8 Deployed Jul 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants