react-native icon indicating copy to clipboard operation
react-native copied to clipboard

App not behaving when not debugging

Open mangogogos opened this issue 11 years ago • 10 comments

I recently changed around some of my logic for the initialization of my application, but I think I've introduced a bug. The problem is that for whatever reason, when I load my app I am faced with only an empty screen but when I connect to the chrome debugging tools everything works exactly as it should. I think that there must be something cached or different between what the js is doing when run through the debugging tools, but without access to console Im having trouble finding the location of what I assume is a bug I introduced. Does anyone know what would cause the app to behave differently when debugging or how I could trace the issue?

mangogogos avatar Oct 21 '15 21:10 mangogogos

this is very very strange. I've never run into this. take a look at the packaged output and run it through a linter. See if there may be erroneous statements or syntax errors that may be causing this.

jaygarcia avatar Oct 22 '15 18:10 jaygarcia

Where can I find the packaged output?

edit: I took a look at the contents of localhost:8081/index.android.bundle and ran it through jshint with node and esnext flags as true but it gave up after about 50 errors. Here is some of the output:

index.android.bundle: line 10, col 1, Missing "use strict" statement. index.android.bundle: line 75, col 22, Expected '{' and instead saw 'if'.

75: for(name in visited) if(hop.call(visited,name)){ 76: unresolved.push(name);}

index.android.bundle: line 205, col 8, 'ret' used out of scope.

199: try{ 200: var ret=require.apply(this,arguments);} 201: catch(e) { 202: global.ErrorUtils.reportFatalError(e);} 203: 204: _inGuard = false; 205: return ret;}

index.android.bundle: line 235, col 4, 'ret' is already defined. index.android.bundle: line 236, col 19, Unexpected use of '&'.

233: dependencies=module.dependencies, 234: length=dependencies.length, 235: ret; 236: if(module.special & USED_AS_TRANSPORT){ 237: length = Math.min(length,factory.length);}

index.android.bundle: line 281, col 17, Expected '!==' and instead saw '!='. index.android.bundle: line 281, col 43, Expected '!==' and instead saw '!='. index.android.bundle: line 426, col 18, Expected '!==' and instead saw '!='. index.android.bundle: line 426, col 48, Expected '!==' and instead saw '!='. index.android.bundle: line 427, col 18, Expected '!==' and instead saw '!='. index.android.bundle: line 493, col 47, Expected an assignment or function call and instead saw an expression.

490: if(!module.waitingMap[dep] && module.id !== dep){ 491: module.waiting++; 492: module.waitingMap[dep] = 1; 493: dependencyMap[dep] || (dependencyMap[dep] = {}); 494: dependencyMap[dep][module.id] = 1;}}

index.android.bundle: line 516, col 43, Unexpected use of '&'. index.android.bundle: line 540, col 19, Unexpected use of '&'. index.android.bundle: line 525, col 1, The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. index.android.bundle: line 612, col 1, Missing "use strict" statement. index.android.bundle: line 613, col 13, Expected '===' and instead saw '=='. index.android.bundle: line 626, col 17, Expected '===' and instead saw '=='. index.android.bundle: line 644, col 1, The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. index.android.bundle: line 790, col 51, Expected '===' and instead saw '=='. index.android.bundle: line 821, col 1, Expected '{' and instead saw 'return'. index.android.bundle: line 829, col 1, Expected '{' and instead saw 'return'. index.android.bundle: line 831, col 1, Expected '{' and instead saw 'return'. index.android.bundle: line 834, col 1, Expected '{' and instead saw 'return'. index.android.bundle: line 926, col 27, Expected '{' and instead saw 'numLinesEst'. index.android.bundle: line 958, col 14, Expected '===' and instead saw '=='. index.android.bundle: line 1150, col 1, Missing "use strict" statement. index.android.bundle: line 1157, col 61, Expected an assignment or function call and instead saw an expression. index.android.bundle: line 1160, col 66, Expected an assignment or function call and instead saw an expression. index.android.bundle: line 1237, col 17, Extending prototype of native object: 'String'. index.android.bundle: line 1239, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1251, col 17, Extending prototype of native object: 'String'. index.android.bundle: line 1253, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1271, col 17, Extending prototype of native object: 'String'. index.android.bundle: line 1273, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1284, col 17, Extending prototype of native object: 'String'. index.android.bundle: line 1286, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1299, col 10, Unexpected use of '&'. index.android.bundle: line 1302, col 10, Unexpected use of '>>='. index.android.bundle: line 1319, col 1, Missing "use strict" statement. index.android.bundle: line 1320, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1329, col 24, Unexpected use of '>>>'. index.android.bundle: line 1354, col 11, Expected '===' and instead saw '=='. index.android.bundle: line 1370, col 1, Missing "use strict" statement. index.android.bundle: line 1424, col 1, Unnecessary semicolon. index.android.bundle: line 1486, col 50, Did you mean to return a conditional instead of an assignment? index.android.bundle: line 1805, col 15, Expected '===' and instead saw '=='. index.android.bundle: line 1869, col 15, Expected '===' and instead saw '=='. index.android.bundle: line 2171, col 1, The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. index.android.bundle: line 2212, col 1, The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. index.android.bundle: line 2354, col 13, Expected '!==' and instead saw '!='. index.android.bundle: line 2354, col 13, Too many errors. (4% scanned).

I embedded a couple of the more interesting ones but so far there hasn't been much to see. Is there a specific linter you would recommend? I could turn off some of the stricter ones (e.g. != vs !==) but is there a specific section of the file I should look at?

mangogogos avatar Oct 23 '15 16:10 mangogogos

I FOUND THE ISSUE! One of my many stylesheets had a couple of duplicates, specifically

blah = StyleSheet.create( { blah1: { flexDirection: 'row', flexDirection: 'row, // aw come on it's just a duplicate you should know what to do! ... }, blah2: { justifyContent: 'center', ... justifyContent: 'flex-start', //whoops this one is pretty erroneous my bad! }, ... } } );

when I would start the application normally having either one of those would independently cause the loading to fail and I would be left with a hanging, empty screen

when I debug the application in chrome, the application runs exactly as it should with blah2 using flex-start IIRC

Hopefully someone can confirm this issue and then add a check for it in stylesheet.create as having this fail silently was a serious head scratcher, especially since everything worked in debugging!

mangogogos avatar Oct 23 '15 21:10 mangogogos

@mangogogos You should use a linter like eslint which can catch these kinds of errors early.

satya164 avatar Oct 25 '15 17:10 satya164

I encountered the same problem. And I found the following reason. I used ECMAScript 6 Features,the keyword "const". and I'm not sure if these features are only surpported in a browser.

I changed const SERVER = 'http://www.yudianer.com/api'; to var SERVER = 'http://www.yudianer.com/api'; , then the problem is fixed.

Maybe you can check if you use some ECMAScript 6 Features.

caohongtao avatar Oct 26 '15 10:10 caohongtao

@caohongtao You can easily add a custom .babelrc to enable ES6 features you need.

satya164 avatar Oct 26 '15 10:10 satya164

I still think there should be a check in place in the stylesheet create method so that this isn't a silent issue but Im going to mark this as closed

mangogogos avatar Oct 26 '15 16:10 mangogogos

@mangogogos I don't think you can catch duplicate properties in objects. It is handled by runtime itself. I strongly suggest you use a linter to avoid obvious programmer errors.

satya164 avatar Oct 26 '15 16:10 satya164

@satya164 just wanted to give a huge thanks for insisting I use eslint!

mangogogos avatar Oct 30 '15 04:10 mangogogos

@mangogogos Glad it helped you :D

satya164 avatar Oct 30 '15 14:10 satya164