Skip to content

[0.77] Restore Metro log streaming via CLI flag#49356

Merged
robhogan merged 1 commit intofacebook:0.77-stablefrom
huntie:0.77-restore-client-logs
Feb 12, 2025
Merged

[0.77] Restore Metro log streaming via CLI flag#49356
robhogan merged 1 commit intofacebook:0.77-stablefrom
huntie:0.77-restore-client-logs

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Feb 12, 2025

Summary

Note

This is a separate version of #49353 / D69469039 targeting the 0.77-stable branch.

This change adds an opt-in to restore JavaScript log streaming via the Metro dev server, removed from React Native core in 0.77.

Users can opt into this legacy behaviour by adding the --client-logs flag to npx @react-native-community/cli start.

  • The default experience remains without streamed JS logs.
  • The existing "JavaScript logs have moved! ..." notice is printed in all cases, and we do not advertise the new flag for new users.
  • Under non-Community CLI dev servers (i.e. Expo), log streaming is restored implicitly.

We will clean up this functionality again when we eventually remove JS log streaming over HMRClient, tasked in T214991636.

Implementation notes

  • Logs are always sent over HMRClient (previous status quo), even with log streaming off in the dev server. This is a necessary evil to be able to flag this functionality in a user-accessible place, and to move fast for 0.78.
  • Necessarily, emitting fusebox_console_notice moves to the dev server itself, on first device (Fusebox) connection.

Changelog:
[General][Added] - Add opt in for legacy Metro log streaming via --client-logs flag

Test Plan

cd packages/rn-tester/
yarn start [--client-logs]

Default

image

✅ RNDT logs warning notice is emitted in dev server
✅ Logs are not visible in dev server
✅ Logs are visible in DevTools
✅ RNDT logs warning is shown once

With --client-logs

image

✅ RNDT logs warning notice is emitted in dev server
✅ Logs are visible in dev server
✅ Logs are visible in DevTools
✅ RNDT logs warning is shown once

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Feb 12, 2025
Summary:
This change adds an opt-in to restore JavaScript log streaming via the Metro dev server, [removed from React Native core in 0.77](https://reactnative.dev/blog/2025/01/21/version-0.77#removal-of-consolelog-streaming-in-metro).

Users can opt into this legacy behaviour by adding the `--client-logs` flag to `npx react-native-community/cli start`.

- The default experience remains without streamed JS logs.
- The existing "JavaScript logs have moved! ..." notice is printed in all cases, and we do not advertise the new flag for new users.
- Under non-Community CLI dev servers (i.e. Expo), log streaming is restored implicitly.

We will clean up this functionality again when we eventually remove JS log streaming over `HMRClient`, tasked in T214991636.

**Implementation notes**

- Logs are always sent over `HMRClient` (previous status quo), even with log streaming off in the dev server. This is a necessary evil to be able to flag this functionality in a user-accessible place, and to move fast for 0.78.
- Necessarily, emitting `fusebox_console_notice` moves to the dev server itself, on first device (Fusebox) connection.

Changelog:
[General][Added] - Add opt in for legacy Metro log streaming via `--client-logs` flag
@huntie huntie force-pushed the 0.77-restore-client-logs branch from 376c2e1 to 453a2b8 Compare February 12, 2025 13:03
@robhogan robhogan merged commit 969eb3f into facebook:0.77-stable Feb 12, 2025
@robhogan
Copy link
Copy Markdown
Contributor

Picks 0d66c52

@huntie huntie deleted the 0.77-restore-client-logs branch April 22, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner Pick Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants