Skip to content

fix(lynx): keep readiness requests alive - #909

Merged
trueadm merged 2 commits into
octanejs:mainfrom
Huxpro:fix/lynx-readiness-signal
Aug 30, 2026
Merged

trueadm merged 2 commits into
octanejs:mainfrom
Huxpro:fix/lynx-readiness-signal

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reproduction

Lynx starts its main-thread and background scripts independently. The background transport can install its receiver and send its first correlated main-ready-request before main installs its receiver. Main's unsolicited request-0 announcement can likewise be emitted before the background receiver exists, so the current one-shot announcement retry does not guarantee that either side observes the other.

The regression test creates the background transport before installing the main harness. Before this change the initial request is lost and transport.ready remains pending. With this change the next readiness pulse reaches main, and the reply resolves the same transport without changing its correlation id.

Accident history

The transport previously depended on startup scheduling making either the initial request or the single announcement-triggered retry cross the listener boundary. That was an accidental liveness guarantee: both messages can be delivered too early on Native even though listener installation is correctly ordered within each script.

#885 fixed the separate transport-materialization failure class; it did not make readiness durable. The same-id readiness/presence semantics were already exercised on Native in Huxpro/octane#233. This patch uses that verified semantic contract while rewriting the implementation around upstream's current transport lifecycle, close path, and completed-request tombstones.

Remove the failure class

  • Keep one recursive 16 ms readiness timer, using Lynx's documented bare global timer API, while the background transport is waiting.
  • Re-send the same frozen request, including the same correlation id, so main's existing tombstone handling keeps late duplicates idempotent.
  • Stop the timer on the correlated reply and on every transport-close path.
  • Treat request 0 as an availability hint that expedites the next same-id pulse.

This changes no protocol keys, capability rungs, first-tree behavior, main-thread implementation, D2 performance-entry code, or program/adoption surface.

getOwnPropertyNames site audit

This PR adds, removes, or changes no Object.getOwnPropertyNames call. Each current Lynx site remains deliberate after #885's transport boundary:

  • packages/lynx/src/core/protocol.ts:599 — retained. It enforces dense arrays and data-property descriptors on already decoded protocol values.
  • packages/lynx/src/core/worklets.ts:152 — retained. It enforces exact enumerable data-property shapes for decoded worklet payloads and rejects accessors/symbol fields.
  • packages/lynx/src/core/lifecycle-data.ts:109 — retained. It validates lifecycle clone inputs above the decoded transport boundary, including array length handling and accessor rejection.
  • packages/lynx/src/core/transport-codec.ts:13 — documentation only, not an executable call site; retained because it records the native bridge accident that fix(lynx): serialize cross-thread transport payloads #885 removed.

The upstream-state correction and validation caveats were reported before this PR in Huxpro/octane#232.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test — the unsharded local run exhausted the shared host's /tmp and file-descriptor limits (ENOSPC/EMFILE), causing 1,314 unrelated suites not to collect; the official CI shards and dedicated heavy/browser/parity jobs are the full-suite gate.
  • official upstream CI run 33311512894 — all four Node 24 test shards, all four React parity shards, heavy package/Astro, heavy Chromium, website, example shards, publishable packages, Three/Lynx compatibility, lint, typecheck, and provenance passed
  • targeted tests:
    • red-before / green-after late-listener regression in packages/lynx/tests/protocol.test.ts
    • pnpm exec vitest run --project lynx — 27 files, 395 tests passed
    • pnpm exec tsgo --noEmit -p packages/lynx/tsconfig.json
    • pnpm exec tsgo --noEmit -p packages/lynx/tsconfig.testing.json
    • pnpm exec tsgo --noEmit -p packages/lynx/typetests/tsconfig.json
    • pnpm typecheck:files packages/lynx/src/core/transport.ts
    • pnpm sync
    • pnpm changeset:check
    • git diff --check
    • disposable main + #909@9994674bba + #886@7378d00477 Native build/load — the corrected bundle exposes the expected 1000-row semantic snapshot with no application error; the leased Explorer identifies as SDK 0.0.1 and lacks both bare and globalThis timer APIs, so readiness-pulse and ACK/two-frame acceptance are deliberately not claimed on that image (evidence)

Risk / follow-ups

The only repeated work is one small same-id transport message every 16 ms before readiness. It stops as soon as readiness resolves or the transport closes. No D2 code is included here; #886's device acceptance will be tested as a disposable stack on top of this PR while #886 itself remains unchanged.

Provenance

  • An agent produced this diff (agent-authored)

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Aug 30, 2026
@github-actions
github-actions Bot marked this pull request as draft August 30, 2026 12:13
@Huxpro
Huxpro marked this pull request as ready for review August 30, 2026 12:14
@Huxpro
Huxpro marked this pull request as draft August 30, 2026 12:19
@Huxpro
Huxpro marked this pull request as ready for review August 30, 2026 12:27
@trueadm
trueadm merged commit 7053028 into octanejs:main Aug 30, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants