Skip to content

DevTools: Add version to protocol used between backend/frontend #21326

Closed
@bvaughn

Description

@bvaughn

The problem

DevTools packages are published to NPM and follow semver for their public APIs (e.g. connectToDevTools from react-devtools-core). However the protocol used to communicate between the "backend" and "frontend" components is unversioned and may change between releases. Normally this does not cause a problem as the browser extensions, react-devtools-inline package, and react-devtools standalone package (used for browsers like Safari) all bundle these components together (e.g. the frontend injects or serves via an embedded web server the backend script so there's a 1:1 match).

However, React Native poses a special challenge. The React Native renderer embeds the "backend" component within renderer itself (in DEV mode), but the user launches the "frontend" UI via NPM or a tool like Flipper or the React Native Debugger. In either case, there is no guarantee that the version of the "frontend" UI will match the version of the embedded "backend". (React Native does specify a react-devtools-core dependency but users are often running a globally installed version of the React DevTools or Flipper and so nothing even checks the dependency version.)

This means that updates to React Native (or more specifically, updates to the embedded DevTools backend) can cause DevTools installations to stop working without an apparent reason or an obvious solution.

The plan

The long term plan going forward (as implemented in #21331) is:

  1. Add an explicit version to the protocol used by the DevTools "backend" and "frontend" components to talk to each other.
  2. Check this protocol during initialization to ensure it matches.
  3. Show upgrade/downgrade instructions if there's a mismatch (or if the check times out without a response– indicating an older backend).
  4. Release this as 4.13.

The short term plan (as implemented in #21344) is:

  1. Branch and make a patch release of DevTools 4.10 that adds a protocol check to the frontend (to detect any newer backends).
  2. Upgrade Flipper (and recommend upgrade for the OSS React Native Debugger as well) to this new frontend.
  3. Wait a week or so for rollout and then upgrade React Native to the 4.13 backend.

Based on my not-very-scientific poll it seems like people mostly use DevTools via NPM, but Flipper and React Native Debugger have a pretty big user share too. The upgrade/downgrade instructions will then be geared primarily to NPM users but with an FBURL that links to a Gist with instructions for these other tools as well.

Checklist

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions