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

[HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js #1032

Closed
dminkovsky opened this issue Jul 12, 2018 · 13 comments

Comments

@dminkovsky
Copy link

dminkovsky commented Jul 12, 2018

I am using react-hot-loader 4.3.3. When my application reloads, I am warned:

[HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js

My index.js and App.js are set up per the README.

Apart for the warnings, the reload seems to work:

[WDS] Hot Module Replacement enabled.
2client:80 [WDS] App updated. Recompiling...
client:212 [WDS] App hot update...
log.js:23 [HMR] Checking for updates on the server...
client:80 [WDS] App updated. Recompiling...
bundle-b55897808298ac6d7154.js:86 [HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js
bundle-b55897808298ac6d7154.js:86 [HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js
log.js:23 [HMR] Updated modules:
log.js:23 [HMR]  - ./src/Private/Message/index.js
log.js:23 [HMR]  - ./src/Private/Message/MessageRouteContainer.js
log.js:23 [HMR]  - ./src/Router.js
log.js:23 [HMR]  - ./src/App.js
log.js:23 [HMR] App is up to date.
client:80 [WDS] App updated. Recompiling...
client:212 [WDS] App hot update...
log.js:23 [HMR] Checking for updates on the server...
log.js:23 [HMR] Nothing hot updated.
log.js:23 [HMR] App is up to date.

But what is the warning about? Is something not working?

The require it's warning about is declared like this (inside App.js, it is output from the Relay compiler):

var query = function query() {
    var node = __webpack_require__("./src/__generated__/AppQuery.graphql.js");

    if (node.hash && node.hash !== 'a664570d8a5c82655bb51085b2463b75') {
        console.error('The definition of \'AppQuery\' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data.');
    }

    return __webpack_require__("./src/__generated__/AppQuery.graphql.js");
};

The warning is thrown at:

/******/          function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars
/******/ 		var me = installedModules[moduleId];
/******/ 		if(!me) return __webpack_require__;
/******/ 		var fn = function(request) {
/******/ 			if(me.hot.active) {   <--- this is false for some reason
/******/ 				if(installedModules[request]) {
/******/ 					if(installedModules[request].parents.indexOf(moduleId) < 0)
/******/ 						installedModules[request].parents.push(moduleId);
/******/ 				} else {
/******/ 					hotCurrentParents = [moduleId];
/******/ 					hotCurrentChildModule = request;
/******/ 				}
/******/ 				if(me.children.indexOf(request) < 0)
/******/ 					me.children.push(request);
/******/ 			} else {
/******/ 	here --->	   console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
/******/ 				hotCurrentParents = [];
/******/ 			}
/******/ 			return __webpack_require__(request);
/******/ 		};
/******/ 		// more ...

For some reason me.hot.active is not true for the App.js module.

I tried including the Relay compiler before and after the hot loader plugin, but it made no difference.

Expected behavior

What you think should happen:

I shouldn't have warnings and everything should work :)

Environment

React Hot Loader version: 4.3.3

Run these commands in the project folder and fill in their results:

  1. node -v: 8.2.1
  2. npm -v: 5.3.0

Then, specify:

  1. Operating system: OS X Yosemite 10.10.5
  2. Browser and version: Chrome 67
@dminkovsky
Copy link
Author

Update: hot reloading seems to be working well. I get this warning in general, though, for various relay queries that got compiled by the relay compiler into the form above, with the require().

@theKashey
Copy link
Collaborator

The problem - hot reloading is not "complete", a few things left unreplaced.
But usually that is about "unchanged" parts, so should be fine for you, and couldn't fight with them from our side yet.

@dminkovsky
Copy link
Author

dminkovsky commented Jul 13, 2018

@theKashey thanks for your response. Yes, I've observed sometimes some old code is left unreplaced after a reload. It seems like a reload replaces code, but then code that was replaced by a prior reload gets "unreplaced." It's odd. I'm still observing it as I develop.

I do get the "unexpected require($relayQuery) from disposed module" warning not just for the hot App module but for modules in general that have these Relay compiler requires.

Anyway, this current setup is still a big improvement for me over my 3.0.0 configuration, which wasn't configured properly to retain state. Wondering what the issue is though.

@theKashey
Copy link
Collaborator

In short - we are not reflecting some changes made in class constructors.

@dminkovsky
Copy link
Author

Is that a problem or should I close the issue?

@Sakots2499
Copy link

2018-07-14T19:27:18.684Z] [info] Bitcoin.com Wallet v4.12.2 #bc326e8

@Sakots2499
Copy link

Sakots2499 commented Jul 14, 2018

gotoon

@Sakots2499
Copy link

[HMR] unexpected require(./src/generated/AppQuery.graphql.js) from disposed module ./src/App.js #1032

@dminkovsky
Copy link
Author

It seems to be working very well. Thank you.

@theKashey
Copy link
Collaborator

@dminkovsky - that is a problem, and we have an issue to track it - #1024

@xinggangling
Copy link

我遇到了同样的问题

@xinggangling
Copy link

image

@dminkovsky
Copy link
Author

dminkovsky commented Jul 17, 2018

@theKashey Haha! I updated to v3 at around the same time it reached its end too :). Very good. Makes sense, thank you again. It's been very fun seeing individual functions swapped out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants