Skip to content

refactor(bridge): replace birpc with internal rpc transport#132

Merged
V3RON merged 4 commits into
mainfrom
refactor/bridge
May 28, 2026
Merged

refactor(bridge): replace birpc with internal rpc transport#132
V3RON merged 4 commits into
mainfrom
refactor/bridge

Conversation

@V3RON

@V3RON V3RON commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

This PR rewrites the Harness bridge to remove birpc and replace it with an internal, typed RPC layer built on top of an explicit bridge protocol. The new bridge separates transport concerns from RPC concerns, validates incoming control messages, and keeps binary screenshot transfer support without relying on a third-party RPC implementation.

This change is needed for Harness users because bridge failures currently tend to show up as stuck runs, ambiguous timeouts, or hard-to-diagnose disconnects when the app reloads, reconnects, crashes, or drops its socket during a test run. The new bridge makes those failure modes deterministic and easier to understand.

Related Issue

None.

Context

Key changes in this rewrite:

  • remove the birpc dependency from @react-native-harness/bridge
  • add an internal protocol for invoke, return, event, ready, ping, and pong messages
  • introduce a typed RPC peer with explicit timeout handling and error serialization/deserialization
  • add transport abstractions for browser and Node WebSocket runtimes instead of coupling bridge logic directly to WebSocket APIs
  • add heartbeat-based liveness detection so dead app connections fail faster
  • treat the newest app connection as authoritative and actively disconnect stale sessions
  • surface disconnects as AppBridgeDisconnectedError so Jest reports bridge loss cleanly instead of leaving failures ambiguous
  • expand bridge test coverage around protocol parsing, RPC behavior, heartbeat handling, and client disconnect behavior

Testing

Added/updated automated coverage for:

  • packages/bridge/src/__tests__/client.test.ts
  • packages/bridge/src/__tests__/heartbeat.test.ts
  • packages/bridge/src/__tests__/protocol.test.ts
  • packages/bridge/src/__tests__/rpc-peer.test.ts
  • packages/jest/src/__tests__/bridge.test.ts
  • packages/jest/src/__tests__/errors.test.ts
  • packages/jest/src/__tests__/execute-run.test.ts

@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview, Comment May 28, 2026 12:03pm

Request Review

@V3RON V3RON changed the title refactor: bridge refactor(bridge): replace birpc with internal rpc transport May 28, 2026
@V3RON
V3RON merged commit bf624b5 into main May 28, 2026
6 checks passed
@V3RON
V3RON deleted the refactor/bridge branch May 28, 2026 12:05
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.

1 participant