question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'code' of undefined

See original GitHub issue

Description

When you turn off Metro bundler while the app is running, two toasts appear:

  1. Cannot connect to Metro (warning)
  2. Cannot read property ‘code’ of undefined (error)

The warning is expected but the error is not.

The issue can be reproduced on a fresh RN 0.71.0-rc.2 app.

Version

0.71.0-rc.2

Output of npx react-native info

System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M1 Pro
    Memory: 94.03 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.11.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - /opt/homebrew/bin/npm
    Watchman: 2022.10.31.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 26, 28, 29, 30, 31, 32, 33
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
      System Images: android-28 | Google APIs ARM 64 v8a, android-28 | Google ARM64-V8a Play ARM 64 v8a, android-33 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.0.0-20221129-2018-43027b6d4 => 0.0.0-20221129-2018-43027b6d4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Initialize a fresh RN app
  2. Start Metro bundler
  3. Launch React Native app
  4. Close Metro bundler
  5. Watch the red toast appear

Snack, code example, screenshot, or link to a repository

Zrzut ekranu 2022-11-30 o 17 25 29 Zrzut ekranu 2022-11-30 o 17 25 40

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
cortinicocommented, Dec 5, 2022

Thanks for reporting this. We looked into it and it’s a regression introduced in .71 inside React Native. We’ll be pushing a fix out (cc @blakef is working on it) and we’ll pick it for RC4 (cc @kelset for visibility).

1reaction
huntiecommented, Dec 20, 2022

However, I noticed that the warning message about lost connection to Metro differs a bit between Android (“Try the following”) and iOS (“1001: Stream end encountered”), is this expected?

I believe this is expected as these are independently defined messages for distinct WebSocket events (defined here and here). However, perhaps we can address this papercut by adding the similar help output on restarting Metro for the close event (the one in your iOS Simulator screenshot).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
What Causes TypeError: Cannot Read Property of Undefined ... Undefined means that a variable has been declared but has not been assigned a...
Read more >
JS/Ionic:TypeError: Cannot read property 'code' of undefined
The error I am getting is: TypeError: Cannot read property 'code' of undefined at services.js:65 What should I do to solve this error?...
Read more >
Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >
Cannot read property 'Code' of undefined · Issue #2861 · aws ...
Describe the bug Periodically, when an SqsClient sends a ReceiveMessageCommand I receive: TypeError: Cannot read property 'Code' of ...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
Check your Code for Common Mistakes · Check for Undefined Before Accessing the Array · Provide an Alternative Value When the Array is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found