LogBox code frames for console.error/warn showing wrong code
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react-native
- Domain
- tooling
Research direction
Start with the linked reproducer and trace Metro's handling of the stack trace used for LogBox code frames, comparing the reported App.tsx line with the displayed View frame. Done means console.error and console.warn code frames point to their actual source lines on iOS.
Written by the indexing model from the issue text.
Description
Description
It appears that in 0.73, code frames are broken, and point to the wrong line. This repos for me by creating an empty project with npx react-native@latest init project, and adding console.log to the top of App.tsx:
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
// 🚩 new line
console.error('HIT');
return ( ... )
}
Expectation
The code frame should point to this line with console.error.
Actual
The code frame points to something inside of View:
Note: the 4th line in the stack trace is the correct line: App.tsx:65 is where the console.error is:
Steps to reproduce
- `npx react-native@latest init myproject.
- Update App.tsx with console.error.
- Obsever LogBox codeframe is incorrect.
React Native Version
0.73.0
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 14.0
CPU: (8) arm64 Apple M2
Memory: 75.41 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.4.0
path: ~/.nvm/versions/node/v20.4.0/bin/node
Yarn:
version: 1.22.19
path: ~/.nvm/versions/node/v20.4.0/bin/yarn
npm:
version: 9.7.2
path: ~/.nvm/versions/node/v20.4.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.12.1
path: /usr/local/bin/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: Not Found
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.0
wanted: 0.73.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
ERROR HIT
at App (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.seventhree:125259:54)
at RCTView
at View (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.seventhree:59687:43)
at RCTView
at View (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.seventhree:59687:43)
at AppContainer (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.seventhree:59529:36)
at seventhree(RootComponent) (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.seventhree:111251:28)
Reproducer
https://github.com/react-native-community/reproducer-react-native
Screenshots and Videos
Above
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 699
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react/metro
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/metro#1927 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Async chunk URLs drop the file extension, so .cjs async imports fail with "Requiring unknown module"Open
Difficulty 3/5 1-2 days Newbie friendliness 74/100
react/metro#1959 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
react/metro#1928 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Edit: RTE News LogoOpencheck:failed logos:edit
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
iptv-org/database#36354 · 1 comment ·
Maintainers usually reply within 4 days
-
status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
midnightntwrk/midnight-wallet#791 ·
Maintainers usually reply within 1 day