Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pretty-format to 29 #45726

Closed
dprevost-LMI opened this issue Jul 26, 2024 · 7 comments
Closed

Upgrade pretty-format to 29 #45726

dprevost-LMI opened this issue Jul 26, 2024 · 7 comments
Labels
Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@dprevost-LMI
Copy link
Contributor

dprevost-LMI commented Jul 26, 2024

Description

For some reason, in our project, at runtime, the react-native code uses the pretty-format v29 while the code expects v26.
A colleague fixed that by using the below patch, but specifying version 26 in our package.json also does the job.

In our project, I saw that Jest uses pretty-format v29, which is undoubtedly somehow related.

Instead of investigating the root cause, I thought upgrading pretty-format would be more beneficial. So, I'm entering this issue for that; see this PR.

diff --git a/node_modules/react-native/Libraries/Utilities/HMRClient.js b/node_modules/react-native/Libraries/Utilities/HMRClient.js
index 03ae287..7f3fd21 100644
--- a/node_modules/react-native/Libraries/Utilities/HMRClient.js
+++ b/node_modules/react-native/Libraries/Utilities/HMRClient.js
@@ -124,7 +124,13 @@ const HMRClient: HMRClientNativeInterface = {
           data: data.map(item =>
             typeof item === 'string'
               ? item
-              : prettyFormat(item, {
+              /* 
+                https://jira.ops.expertcity.com/browse/GTCMOB-5830
+                fix for console.log that stopped working after RN 71
+                the require for prettyFormat is importing the wrong version (high major version which has the breaking change)
+                in this package it should be ^26 but it is pulling ^29 
+              */
+              : prettyFormat.format(item, {
                   escapeString: true,
                   highlight: true,
                   maxDepth: 3,

Steps to reproduce

Do a console like console.log('index.native.js', { myObject: 'myvalue' }); and nothing is output
Do console.log('index.native.js') and it is output

React Native Version

0.73.9

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX has cached version (0.73.9) != current release (0.74.3)

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M2 Pro
  Memory: 4.53 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.19.1
    path: ~/.nvm/versions/node/v18.19.1/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v18.19.1/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/dprevost/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.8
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /Users/dprevost/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native:
    installed: 0.73.9
    wanted: 0.73.9
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

None

Reproducer

https://github.com/facebook/react-native/pull/45732/files

Screenshots and Videos

No response

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jul 26, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@react-native-bot
Copy link
Collaborator

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@react-native-bot react-native-bot added Stale There has been a lack of activity on this issue and it may be closed soon. and removed Stale There has been a lack of activity on this issue and it may be closed soon. labels Aug 23, 2024
@dprevost-LMI
Copy link
Contributor Author

I link the PR fixing this, should we only keep the PR open and close this issue?

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Aug 27, 2024
@cortinico
Copy link
Contributor

Upgrade pretty-format to v29 #45732

We can keep it open and will close automatically once the linked PR will merge

facebook-github-bot pushed a commit to facebook/metro that referenced this issue Aug 28, 2024
Summary:
As described in [this issue](facebook/react-native#45726), we had a problem where, at runtime, version v29 instead of v26 was used, so upgrading it is the fastest fix.

## Changelog:

[GENERAL] [CHANGED] - Upgrade pretty-format to 29.7.0

<!--
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

X-link: facebook/react-native#45732

Reviewed By: blakef

Differential Revision: D60533197

Pulled By: tdn120

fbshipit-source-id: b83dbfe463971abbf00cfebdcc9e5dd6975de0d8
facebook-github-bot pushed a commit that referenced this issue Aug 28, 2024
Summary:
As described in [this issue](#45726), we had a problem where, at runtime, version v29 instead of v26 was used, so upgrading it is the fastest fix.

## Changelog:

[GENERAL] [CHANGED] - Upgrade pretty-format to 29.7.0

<!--
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #45732

Test Plan:
I use console log in the RN tester app
![image](https://github.com/user-attachments/assets/3e3ab0d1-e32b-4b73-8f00-cbd8f040c5aa)

Reviewed By: blakef

Differential Revision: D60533197

Pulled By: tdn120

fbshipit-source-id: b83dbfe463971abbf00cfebdcc9e5dd6975de0d8
@mateoguzmana
Copy link
Contributor

This was already fixed in 7bc9244 but seems like the PR did not close this one this time

@cortinico
Copy link
Contributor

This was already fixed in 7bc9244 but seems like the PR did not close this one this time

True thanks for pointing this out @mateoguzmana !

@cortinico cortinico added Resolution: Fixed A PR that fixes this issue has been merged. and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants