ghost line does nothing even when viewing through the Node debugger? - javascript

I have the weirdest bug I have ever seen. I recently upgraded my config package and my Google strategy started failing.
I used the debugger to troubleshoot this error:
In the debugger I got to the line were the internal authorizationURL is supposed to be set:
I even set a watch on it ( it is a property on the options object )
Here is a closeup of the line that does nothing, I call it the ghost line:
I stepped through the code line by line and that particular line does nothing for some reason.
For a reality check I put it in a fiddle / replit:
https://repl.it/#johnmorsey/OpenQueasyHashmap
I have no idea how updating my config package has caused this internal error in Passport - Google Strategy.
In my mind the authorizationURL is clearly an internal property that is being set though "ghosting" in the debugger. But in reality my app is crashing b.c. of the error.

Related

babel-polyfill messed with Object in IE11

I have a 1-year-old React app with Server Render that had been in production for a while,
However, it was detected a couple of days before that somehow, the app stop to work with IE11. This is really weird because we have been tested on IE11 many times and it worked before. We even try to roll back the project (using tagged docker image) and this error still appears.
The root cause appears to be in babel-polyfill that somehow change the way Object is created in IE11.
The created object will have jscomp_symbol_Symbol.toStringTag1" Array Iterator"
Here's what I found on the console:
try this input console.log({}) if you have IE11 it will output differently.
This somehow causing my web app to fail since every object will fail lodash _.isPlainObject which is the condition inside Redux.

WebStorm all initialized variables throw error expected BEGIN_ARRAY was BEGIN_OBJECT

I have the following problem:
I have recently started working on another PC with WebStorm 2016.1.3.
The code that was written before that on the previous PC works fine. But writing on this one, screws everything up.
Whatever variable I initialize, I get error:
com.google.gson.JsonParseException expected BEGIN_ARRAY was BEGIN_OBJECT at line 1 column 1217.
Here is debug snapshot:
You can see how the first array is okay, but the rest is just screwed. Really weird problem, and I suspect the IDE. Anyone had that issue?
There was a problem with the cache of the browser and the IDE. It fixed itself after restart and cache kill.

web-component-tester fails for yeoman generator-polymer

With the default Polymer app setup provided from Yeoman generator-polymer 0.7.2 with Gulp selected, Web Component Tester (gulp test:local) is failing with the following error when testing Chrome versions 42 and 43:
Cannot read property 'querySelector' of null
at Context. at /app/test/yo-greeting-basic.html:22:0
Line 22 of yo-greeting-basic.html looks like this:
var header = el.shadowRoot.querySelector('h1');
so it seems the problem is a lack of shadow DOM support.
I also get the error
Cannot read property 'push' of undefined
at Context. at /app/test/yo-list-basic.html:23:0
where lines 22-23 of yo-list-basic.html are
var el = document.querySelector('yo-list');
el.items.push('Foo');
and yo-list is the name of the Polymer element defined in yo-list.html. I'm guessing it's the same issue -- the items aren't found because they're in the shadow DOM.
I'm on OS X Yosemite 10.10.3 and I have Chrome 42 and 43 installed.
I understand that Chrome Driver 2.14 has shadow DOM support but I haven't been able to find documentation for setting it up with web-component-tester.
Can someone tell me what I need to do to get these tests to work?
The error you're seeing is probably because WCT is running its own server and 404ing on the resources coming from bower_components. A recent change moved the bower_components dir out of app and it looks like that broke wct. I'll fix this in the next release which should be going out very soon. I'll update this answer when the new release lands.

Getting more information from “SyntaxError: Parse error” message in PhantomJS/CasperJS

I have a long CasperJS script. When I run it I get:
phantomjs file.js
SyntaxError: Parse error
Is there a way to get some more information about the error.
At least a line number? or any hint at all?
Try run the file.js with node, so for your example:
node file.js
It's not possible to determine this in PhantomJS itself. The documentation on phantom.onError says:
This is the closest it gets to having a global error handler in PhantomJS
And this doesn't catch the syntax error. If you try to run it with the --debug=true option, you will see a lot of debug messages, but the final error has still the same amount of information.
Another thing that I tried was to use a second PhantomJS script which reads the original script and tries to eval it. The phantom.onError event is triggered in this case, but the trace argument is empty.
The good thing is that PhantomJS/CasperJS scripts are just JavaScript, so you can paste them to http://jslint.com/ or run a dedicated jslinter on them to see where the problem lies. There are some options that you have to mark on the site or otherwise you will get a lot of errors:
add phantom to the global variables box,
enable node.js mode and
tolerate "everything" (or those things that you actually want to tolerate)
I spent a whole 8hrs on this to find a trick for this problem. The trick is to run "phantomjs" and type 'require "path_to_js_file"'. I used 2.1.1 version of phantomjs. Likely 2.2 also works.
Then there will be a stack trace that shows which line is the offender. You won't see this in testem output.
In my case, if you define a property twice for an object, it will work for chrome, firefox etc, but not phantomjs. Lint might help but there are >5K lint errors for the project I work on and it is practically impossible to see what's wrong. Also the particular problem is likely hidden under the same bucket of "javascript strict mode violation". Nodejs didn't complain this either.

TypeError: 'undefined' is not an object (evaluating 'requireDirs.forEach')

So, I was transitioning code from windows to linux today to make sure everything works. I managed to break casper/phantom and I'm not even sure how.
Here's my command that runs a casper script on linux (ubuntu 12.14):
/usr/bin/casperjs /var/www/tekalyze/phantom/get_site_info.js --jquery-path="/var/www/tekalyze/js/jquery-1.10.2.min.js" --uri-path=" /var/www/tekalyze/phantom/URI.js" --log-path="/var/www/tekalyze/phantom/casper.log" --data-url=http://tekalyze.com/ajax.php --id='19' --url='http://www.bk.com/?utm_source=LOCATIONiq&utm_medium=locallstgs&utm_campaign=2013' --log-level=debug
It's giving me this:
TypeError: 'undefined' is not an object (evaluating 'requireDirs.forEach')
in module (./get_all_urls:102)
/var/www/tekalyze/phantom/get_all_urls.js:102 in _require
/var/www/tekalyze/phantom:13 in anonymous
/home/casper/casperjs/bin/bootstrap.js:146 in _require
/var/www/tekalyze/phantom/get_site_info.js:8
/var/www/tekalyze/phantom/get_site_info.js:228
line 102 of get_all_urls is:
crawl.call(this, links[currentLink]);
I've tried commenting it out, and the stack trace remains the same, which leads me to believe it's not related.
The relevant file can be found here.
I'm honestly just scratching my head. I looked at bootstrap.js:146 and saw something about phantom.casperPath, but I hadn't had to set an environment variable in windows, so I'm not sure about this for linux. The relevant line is this: if (!phantom.casperPath) -- which leads me to believe I could get this to work if I re-write everything to start from phantom first, then set all of the casper variables, but I haven't verified whether or not that will work yet.
Also, I used this script to install them both, so the directories should be set up correctly.
It turns out this functionality isn't added until 1.1.0-DEV, so updating to that instead of using 1.0.0 on linux is the best solution.

Categories

Resources