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

Runtime error after upgrade to React Native 0.61 - "TypeError: hmrClient.send is not a function" #26958

Closed
huntie opened this issue Oct 22, 2019 · 8 comments
Labels
Bug Resolution: Locked This issue was locked by the bot.

Comments

@huntie
Copy link
Member

huntie commented Oct 22, 2019

I am in the process of updating an existing project from react-native 0.60.4 to 0.61.2. The app is successfully packaged and installs on my local iOS Simulator. The Metro Bundler successfully serves the app to the device. My observations are as follows:

  • Upon running, a red screen error headlined TypeError: hmrClient.send is not a function. is displayed on every launch, regardless of whether Fast Refresh is enabled or disabled.
  • This red screen message can be dismissed, and underneath I have a functional, navigable application.
  • No Fast Refresh functionality works when enabled, most likely tied directly to this.

React Native version:

yarn run v1.19.1
$ /Users/alex/Development/<project>/node_modules/.bin/react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
    Memory: 141.59 MB / 16.00 GB
    Shell: 3.0.2 - /usr/local/bin/fish
  Binaries:
    Node: 10.16.3 - /var/folders/t_/q6_rnx915r38lst_z95l6swh0000gn/T/yarn--1571762447670-0.2398560026433516/node
    Yarn: 1.19.1 - /var/folders/t_/q6_rnx915r38lst_z95l6swh0000gn/T/yarn--1571762447670-0.2398560026433516/yarn
    npm: 6.11.3 - ~/.config/nvm/10.16.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.2 => 0.61.2
Done in 7.47s.

Error output

Simulator Screen Shot - iPhone 11 Pro - 2019-10-22 at 17 39 19

TypeError: hmrClient.send is not a function. (In 'hmrClient.send(JSON.stringify({
        type: 'log-opt-in'
      }))', 'hmrClient.send' is undefined)

enable
    HMRClient.js:70:19
setup
    HMRClient.js:241:6
callFunctionReturnFlushedQueue
    [native code]:0

Other notes

Interestingly, this isn't caught by this preceding invariant statement in the enable or disable members of HMRClient. I suspect it's related to some misalignment within HMRClient.js or any corresponding native code.

invariant(hmrClient, 'Expected HMRClient.setup() call at startup.');
const LoadingView = require('./LoadingView');
// We use this for internal logging only.
// It doesn't affect the logic.
hmrClient.send(JSON.stringify({type: 'log-opt-in'}));

@huntie huntie added the Bug label Oct 22, 2019
@AlexUzan
Copy link

What fixed it for me was to update metro, metro-core and metro-react-native-babel-preset to 0.56
In the end I chose to remove metro and metro-core because it seems they are no longer needed, but just updating them should do the trick

@erwamartin
Copy link

I just upgraded to React Native 0.61.4 and I'm getting this issue.
And I also upgraded metro-react-native-babel-preset to 0.56 and tried 0.57 but it doesn't solve my issue.
I confirm that I can just dismiss the error and everything work but Fast Refresh doesn't seem to be working.

@fdobre
Copy link

fdobre commented Nov 21, 2019

I am getting this too after an upgrade from 0.59.10 to 0.61.4. I don't have metro and metro-core and metro-react-native-babel-preset is already set to 0.56 but still getting the error. Has anybody found a fix for this?

@sibelius
Copy link

@AlexUzan what exactly packages do you upgrade to 0.56 ?

@huntie
Copy link
Member Author

huntie commented Nov 26, 2019

Thanks all! Got back to this today and can confirm that for me this was caused by a project-level dependency on metro-config@^0.55.0. Since this is a caret range match which treats 0.56.0 as incompatible, this meant that I still had 0.55.0 installed local to the project. I then have a Yarn Workspaces setup which meant this version was selected by the Metro Bundler. Closing the issue as this is therefore a project configuration problem and not a bug in React Native.

@Doenja
Copy link

Doenja commented Dec 10, 2020

I had the same issue with a React Native app, initialised without the use of expo. 'hrmClient.send is not a function' displayed every time I build/refreshed my app and fast refresh was not working.

This fixed my problem:
yarn add metro@0.56.0

from: https://www.gitmemory.com/issue/react-native-community/releases/140/530142204

@IbrahimSulai
Copy link

I had the same issue with a React Native app, initialised without the use of expo. 'hrmClient.send is not a function' displayed every time I build/refreshed my app and fast refresh was not working.

This fixed my problem:
yarn add metro@0.56.0

from: https://www.gitmemory.com/issue/react-native-community/releases/140/530142204

This worked for me...Thanks a lot 👍

@marinamuse
Copy link

I had the same issue. For me the fix was to delete the react-native-paper package (it was causing the issue) and yarn add metro@0.56.0 thanks to @Doenja

@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants