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

[Android][0.24.1][Windows] packager not update when change js file content #7257

Closed
InnerPeace080 opened this issue Apr 27, 2016 · 26 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@InnerPeace080
Copy link
Contributor

after i update react native to 0.24.1, I modify javascript code and save but packager server not detect this change. So reload js from my android have no effect.

anybody has some advance, thank very much.

@radko93
Copy link
Contributor

radko93 commented Apr 27, 2016

Have you tried restarting you packager/emulator/computer? Maybe check this issue: #306. Look at watchman, auto-saving.

@InnerPeace080
Copy link
Contributor Author

restart packager , computer have no effect. i have no idea with this

@taxusyew
Copy link

taxusyew commented Apr 28, 2016

+1, I got the same problem, live load and hot load both not working.
The js file only transformed once when I start the packager.
It also toke so long time to finish. here is the log :

[11:52:39] request:/index.android.bundle?platform=android&dev=true&hot=t
rue&minify=false
[11:52:39] find dependencies
[11:56:49] Crawling File System (261278ms)
[11:56:49] Building in-memory fs for JavaScript
[11:56:51] Building in-memory fs for JavaScript (1743ms)
[11:56:51] Building in-memory fs for Assets
[11:56:52] Building in-memory fs for Assets (1166ms)
[11:56:52] Building Haste Map
[11:56:53] Building (deprecated) Asset Map
[11:56:53] Building (deprecated) Asset Map (307ms)
[11:56:53] Building Haste Map (758ms)
[11:56:53] Building Dependency Graph (264980ms)
transformed 528/528 (100%)
[11:56:59] find dependencies (260047ms)
[11:56:59] request:/index.android.bundle?platform=android&dev=true&hot=t
rue&minify=false (260291ms)
[Hot Module Replacement] Client connected

@InnerPeace080
Copy link
Contributor Author

InnerPeace080 commented Apr 28, 2016

at last . I found problem.

problem still is timeout . but when timeout it not show message for us (still don't know why.).

to solve this problem.

in file "\node_modules\node-haste\lib\FileWatcher\index.js"
you should increase "MAX_WAIT_TIME" variable (example : 360000) ;

and change function "_createWatcher"
from

key: '_createWatcher',
    value: function _createWatcher(rootConfig) {
      var watcher = new WatcherClass(rootConfig.dir, {
        glob: rootConfig.globs,
        dot: false
      });

      return new Promise(function (resolve, reject) {
        var rejectTimeout = setTimeout(function () {
          return reject(new Error(timeoutMessage(WatcherClass)));
        }, MAX_WAIT_TIME);

        watcher.once('ready', function () {
          clearTimeout(rejectTimeout);
          resolve(watcher);
        });
      });
    }

to

key: '_createWatcher',
    value: function _createWatcher(rootConfig) {
      var watcher = new WatcherClass(rootConfig.dir, {
        glob: rootConfig.globs,
        dot: false
      });

      return new Promise(function (resolve, reject) {

        const rejectTimeout = setTimeout(function() {
          reject(new Error([
            'Watcher took too long to load',
            'Try running `watchman version` from your terminal',
            'https://facebook.github.io/watchman/docs/troubleshooting.html',
          ].join('\n')));
        }, MAX_WAIT_TIME);

        watcher.once('ready', function () {
          clearTimeout(rejectTimeout);
          resolve(watcher);
        });
      });
    }

now . every thing run normal . :D

@tahaziadeh
Copy link

tahaziadeh commented May 27, 2016

great solution InnerPeace080:+1:

@shtefanntz
Copy link
Contributor

Thanks a lot, PeaceFromInside080 !!! ^_^

@xiDaiDai
Copy link

xiDaiDai commented Jul 12, 2016

How to deal with Windows Platform?
"\node-haste\lib\FileWatcher\index.js" how can I get this file ?install watchman?

@xiDaiDai
Copy link

finally got the file path :\node_modules\react-native\node_modules\node-haste

@micsay
Copy link

micsay commented Jul 12, 2016

thanks

@togayther
Copy link

thanks, that's work.

@nishil-tamboli
Copy link

I was stuck with this one for hours. @InnerPeace080 your solution saved my life! Amazing! :)

@TranTungVGroup
Copy link

You saved my day. Your solution works perfect. Thank you so much !!!!

@saintograph
Copy link

For the benefit of future Googlers, MAX_WAIT_TIME is located here :

\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\

@cirojr
Copy link

cirojr commented Sep 28, 2016

Thank you very much @InnerPeace080! I was stucked in this for hours!

@vicmpen
Copy link

vicmpen commented Sep 29, 2016

Thank you all From the bottom of Stavro's heart!

@MoLow
Copy link

MoLow commented Oct 11, 2016

thanks!

@nearchan
Copy link

update node.js to 6.x may works

@nrgwsth
Copy link

nrgwsth commented Oct 19, 2016

Thank you @InnerPeace080 . On my windows system file path was :node_modules\react-native\packager\react-packager\src\node-haste\Filewatcher.

@neilhanekom
Copy link

This not good. The code is now like this. Error come up when I do replace

`_createWatcher(rootConfig) {
const watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false,
});

return new Promise((resolve, reject) => {
  const rejectTimeout = setTimeout(
    () => reject(new Error(timeoutMessage(WatcherClass))),
    MAX_WAIT_TIME
  );

  watcher.once('ready', () => {
    clearTimeout(rejectTimeout);
    resolve(watcher);
  });
});

}`

@lowdev
Copy link

lowdev commented Oct 23, 2016

Niccee!!!! Thank You !!!!

@1mike12
Copy link
Contributor

1mike12 commented Nov 2, 2016

@neilhanekom I'm in the process of testing this myself, but you can still change the pertinent value MAX_WAIT_TIME to the new value. Scroll up to where that const is declared.

EDIT

Totally still works, you don't have to replace the entire function, just change the value of the const.

facebook-github-bot pushed a commit that referenced this issue Nov 4, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes #8784 #7257
Closes #10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
brentvatne pushed a commit to expo/react-native that referenced this issue Nov 5, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
terribleben pushed a commit to expo/react-native that referenced this issue Nov 7, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
ide pushed a commit to expo/react-native that referenced this issue Nov 23, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
ide pushed a commit to expo/react-native that referenced this issue Nov 23, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
ide pushed a commit to expo/react-native that referenced this issue Nov 30, 2016
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this issue Jan 4, 2017
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook#8784 facebook#7257
Closes facebook#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
cpojer pushed a commit to facebook/metro that referenced this issue Jan 26, 2017
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes facebook/react-native#8784 facebook/react-native#7257
Closes facebook/react-native#10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
@rastogitech
Copy link

rastogitech commented Oct 30, 2017

I could not find node-haste folder in my node_modules folder.

@oykhaha
Copy link

oykhaha commented Nov 2, 2017

I could not find FileWatcher in my folder

@rastogitech
Copy link

I gave my hours in finding FileWatcher in my folder but couldn't find. But anyways, in my case, the problem due to which my app wasn't updating on js fiile change is that somehow, using "npm run anroid" command, my app was by default running in production mode (that I came to know from cmd prompt). Then I restarted my system and things started working fine.

@SupaMario123
Copy link

SupaMario123 commented Nov 15, 2017

My Problem was the following:
I think trough executing
"react-native bundle --platform android --dev true --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
i edited the BuildConfig.class from react-native and then i had to build the whole project another time and execute "react-native run-android" to see the changes every time.

I solved the problem through overriding the BuildConfig.class from:

public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String APPLICATION_ID = "com.facebook.react";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
public static final int EXOPACKAGE_FLAGS = 0;
public static final boolean IS_INTERNAL_BUILD = false;

public BuildConfig() {
}

}

to:

public final class CustomBuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.xxx";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}

@zjkhiyori
Copy link

I have this problem too, my react native version is 0.54.0, i restarted my system like rastogitech do, then it work fine...

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

No branches or pull requests