meteor-hmr
meteor-hmr copied to clipboard
Seems to rely on settings.json when run in Cordova
Description of Problem
When run in Cordova gadicc_modules-runtime-hot.js
dies trying to access Meteor.settings.public
.
If I include the following (empty) settings.json using --settings
on the command line then the problem does not occur:
{
"public": {
"nothing": "to see here"
}
}
Please copy and paste the full error from the console, if one occcured.
I20160903-09:35:51.657(8)? 09-03 09:35:49.197 28906 28906 I chromium: [INFO:CONSOLE(572)] "Uncaught TypeError: Cannot read property 'public' of undefined", source: http://localhost:12088/packages/gadicc_modules-runtime-hot.js?hash=7fef6ebd35eb522e3da1341c37b2e0a89ae117ae (572)
This is the offending line in gadicc_modules-runtime-hot.js
:
// On both the client & server this means no hotloading is present
if (!Meteor.settings.public.HOT_PORT)
return;
Environment
- Meteor version: [email protected]
- ecmascript-hot version: gadicc:[email protected]
- Operating System: Mac OS X El Capitan
Supporting files
.meteor/packages
.meteor/packages
[email protected] # Packages every Meteor app needs to have [email protected] # Packages for a great mobile UX [email protected] # The database Meteor supports right now [email protected] # Meteor's client-side reactive programming library
[email protected] # CSS minifier run for production mode [email protected] # JS minifier run for production mode [email protected] # ECMAScript 5 compatibility for older browsers.
[email protected] # Account management based on passwords (other services can be added) meteorhacks:unblock # Allow parallel (per-client) processing of subscriptions [email protected] # Needed to include html/css after removing blaze xolvio:backdoor # Run arbitrary code on server in acceptance tests dburles:factory # Document factory for tests aldeed:collection2 # Document schema checking alanning:roles reywood:publish-composite gadicc:[email protected] meteorhacks:aggregate mizzao:timesync [email protected] [email protected]
.meteor/versions
.meteor/versions
[email protected]
[email protected]
alanning:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
dburles:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
gadicc:[email protected]
gadicc:[email protected]
gadicc:[email protected]
gadicc:[email protected]
gadicc:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
mdg:[email protected]
[email protected]
[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
[email protected]
[email protected]
[email protected]
mizzao:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
raix:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
reywood:[email protected]
[email protected]
sanjo:[email protected]_1
sanjo:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
xolvio:[email protected]
packages.json
packages.json
{
"name": "inspector-gadget",
"private": true,
"scripts": {
"web:storybook": "start-storybook -p 9001 -c ../web/tests/storybook",
"mobile:storybook": "start-storybook -p 9002 -c ../mobile/tests/storybook"
},
"dependencies": {
"@mindhive/meteor": "^3.15.1",
"babel-polyfill": "^6.13.0",
"bcrypt": "^0.8.7",
"date-fns": "^1.3.0",
"enumify": "^1.0.4",
"file-uri-to-path": "0.0.2",
"is-promise": "^2.1.0",
"keycode": "^2.1.4",
"lru-memoize": "^1.0.1",
"material-ui": "^0.15.4",
"meteor-node-stubs": "^0.2.3",
"mobx": "^2.4.3",
"mobx-react": "^3.5.5",
"react": "^15.3.1",
"react-addons-css-transition-group": "^15.3.1",
"react-addons-pure-render-mixin": "^15.3.1",
"react-addons-transition-group": "^15.3.1",
"react-custom-scrollbars": "^4.0.0",
"react-dimensions": "^1.3.0",
"react-dom": "^15.3.1",
"react-event-listener": "^0.2.1",
"react-helmet": "^3.1.0",
"react-hot-loader": "^3.0.0-beta.2",
"react-measure-it": "^0.1.1",
"react-native-listener": "^1.0.1",
"react-redux": "^4.4.5",
"react-router": "^2.6.1",
"react-scrollbar": "^0.4.1",
"react-tap-event-plugin": "^1.0.0",
"redux": "^3.5.2",
"redux-form": "^6.0.0-rc.4",
"redux-form-material-ui": "4.0.1",
"redux-thunk": "^2.1.0",
"shallowequal": "^0.2.2",
"tinycolor2": "^1.4.1"
},
"devDependencies": {
"@kadira/storybook": "^2.3.0",
"@mindhive/di": "^1.1.1",
"@mindhive/some": "^2.4.0",
"array-shuffle": "^1.0.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"chai-datetime": "^1.4.1",
"chai-enzyme": "^0.5.0",
"chai-properties": "vbardales/chai-properties#pull/8/head",
"enzyme": "^2.4.1",
"mobx-react-devtools": "^4.2.4",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^15.3.1",
"redbox-react": "^1.3.0",
"redux-mock-store": "^1.1.4",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0",
"sinon-stub-promise": "^3.0.1",
"style-loader": "^0.13.1"
}
}
.babelrc
(if you modified it)
.babelrc
(if you modified it){
"presets": [
"react",
"es2015",
"stage-0"
],
"plugins": [
"transform-decorators-legacy"
],
"env": {
"development": {
"plugins": [
"react-hot-loader/babel"
]
}
}
}
Hey, thanks for the detailed report!
I've never tested in Cordova, I'll be interested to know how it works. Sounds like it should be ok if you use a settings.json
with:
{
"public": {
"HOT_PORT": 3002
}
}
The port is usually 3002 or 2 ports after your Meteor port (more details in the README). Let me know and I'll add this to the README if it works :)
Apologies. I'm only getting to try this now. With the HOT_PORT specified as above I don't get any errors, but I also don't get any connected
or similar messages from HMR. Here's the log plus what happens after making a change (HCP):
=> Started proxy.
WARNING: You are testing your app on a remote device. For the mobile app to be
able to connect to the local server, make sure your device is on the
same network, and that the network configuration allows clients to
talk to each other (no client isolation).
=> Started your app.
=> App running at: http://localhost:3040/
=> Started app on Android Device.
I20160913-12:17:46.192(9)? 09-13 12:17:43.507 31595 31595 I chromium: [INFO:library_loader_hooks.cc(151)] Chromium logging enabled: level = 0, default verbosity = 0
I20160913-12:17:46.269(9)? 09-13 12:17:44.718 31595 31595 I MeteorWebApp: Serving asset bundle with version: 148dde15b63585e82866e982cd4956305df12331
I20160913-12:17:51.155(9)? 09-13 12:17:50.687 31595 31595 I chromium: [INFO:CONSOLE(1185)] "deviceready has not fired after 5 seconds.", source: http://localhost:12088/cordova.js (1185)
I20160913-12:17:51.156(9)? 09-13 12:17:50.687 31595 31595 I chromium: [INFO:CONSOLE(1178)] "Channel not fired: onDOMContentLoaded", source: http://localhost:12088/cordova.js (1178)
I20160913-12:17:51.337(9)? 09-13 12:17:50.849 31595 31595 I chromium: [INFO:CONSOLE(958)] "Accounts.config was called on the client but not on the server; some configuration options may not take effect.", source: http://localhost:12088/packages/meteor.js?hash=0b0ea1099ba8153bbbc5fb555a755bdff3cec0c3 (958)
=> Meteor server restartedI20160913-12:20:05.096(9)? 09-13 12:20:04.626 31595 31595 I MeteorWebApp: Serving asset bundle with version: b34df351ac060ba28b0a9feeaee55e9b6a93fb8f
I20160913-12:20:11.111(9)? 09-13 12:20:10.643 31595 31595 I chromium: [INFO:CONSOLE(1185)] "deviceready has not fired after 5 seconds.", source: http://localhost:12088/cordova.js (1185)
I20160913-12:20:11.112(9)? 09-13 12:20:10.645 31595 31595 I chromium: [INFO:CONSOLE(1178)] "Channel not fired: onDOMContentLoaded", source: http://localhost:12088/cordova.js (1178)
Also, if I don't put the HOT_PORT in myself (just the original settings.json
I posted at the top) and output __meteor_runtime_config__
then on the server I get:
I20160913-12:28:04.734(9)? "PUBLIC_SETTINGS": {
I20160913-12:28:04.734(9)? "nothing": "to see here",
I20160913-12:28:04.734(9)? "HOT_PORT": 3042
I20160913-12:28:04.734(9)? },
So meteor-hmr
is getting it in there. But on the client:
I20160913-12:28:54.321(9)? 09-13 12:28:53.833 5317 5317 I chromium: "PUBLIC_SETTINGS": {
I20160913-12:28:54.321(9)? 09-13 12:28:53.833 5317 5317 I chromium: "nothing": "to see here"
I20160913-12:28:54.321(9)? 09-13 12:28:53.833 5317 5317 I chromium: }
So, it appears the HOT_PORT setting is not getting through. Also, "accountsConfigCalled": true
must not be getting through either because of the Accounts.config was called on the client but not on the server
I'm getting in the logs. So maybe this is actually some other issue getting in the way. I'll file a Meteor issue about the Accounts.config
not working and see if that solves it.
More stangeness. If I meteor reset
(which I do often with Cordova) then the first time I run after that I don't get Starting gadicc:hot-build Accelerator...
. The second and subsequent times I do. That's why it wasn't starting above. Not sure if you'd like me to open a new issue for that or not?
When it does start I now get a new error.
gadicc_hot.js:97 Uncaught TypeError: Cannot read property '_collection' of undefined
Here's that code:
// If find() was called before we load //
var queries = Autoupdate._ClientVersions._collection.queries; // 39
for (var key in queries) { // 40
queries[key].changed = augmentChanged(queries[key].changed); // 41
} // 42
gadicc_hot.js:97 Uncaught TypeError: Cannot read property '_collection' of undefined
I can confirm this, happens here as well.
I'm going to add Uncaught TypeError: Cannot read property '_collection' of undefined
as a new issue.
Offtopic: @damonmaria can you please explain how you build the cordova app. I'm trying to solve the problem of Cannot read property 'public' of undefined
in production with no luck at all...
@alvelig When I run it locally I use: meteor --settings blank-settings.json run android-device
Where blank-settings.json
is:
{
"public": {
"workaround": "meteor-hmr bug in cordova"
}
}
So there is no longer the missing public
key of Meteor.settings
.
To build my APK I also use the same workaround: meteor build ../deploy/build --server ${MOBILE_SERVER_HOSTNAME} --mobile-settings blank-settings.json
. But I'm not sure this is needed since when run in production mode meteor-hmr
gets out of the way.
@damonmaria Thank you very much! Yes it's necessary... With meteor build ... --mobile-settings
the problem goes away. Not sure if it is related directly to meteor-hmr
, or general meteor bundling, thank you anyway!
Strange. meteor-hmr
gets out of the way when running in 'production', so I would have thought the same thing would happen with a meteor build