Debugging and Fixing Local Karma PhantomJS Issue

Debugging and Fixing Local Karma PhantomJS Issue

Using Karma for a client AngularJS project. Technically there is only one Karma test (a stub success test) since we haven’t gotten around to using that yet. But it is set up and part of our test build chain. Using Mocha for Node tests (controllers, models) and Protractor for end-to-end testing.

So I am running Karma locally, and all of a sudden getting some PhantomJS issues. The results look something like:

$ grunt test:karma --debug
Running "env:test" (env) task
[D] Task source: myproject/node_modules/grunt-env/tasks/env.js

Running "karma:unit" (karma) task
[D] Task source: myproject/node_modules/grunt-karma/tasks/grunt-karma.js
INFO [karma]: Karma v0.12.23 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start PhantomJS again (1/2).
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start PhantomJS again (2/2).
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
ERROR [launcher]: PhantomJS failed 2 times (timeout). Giving up.
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

It would try again after a bit and continually fail. The continuous integration server and other developers’ machines are working just fine. Usually you hear “works on my machine”. Well in this case, it didn’t work on my machine, but worked everywhere else.

Strangely enough, I could access http://localhost:9876 through a browser even without the grunt task running (it said “Not Found” instead of the typical Chrome server not running message.) So I figured maybe something else was listening on that port. I killed all node and grunt and karma and phantomjs-like things, but it was still not working.

So on my Mac:

$ lsof -n -i4TCP:9876 | grep LISTEN
Emacs-10. 30723 anthonypanozzo    9u  IPv4 0x866a47118fd21843      0t0  TCP 127.0.0.1:sd (LISTEN)

Emacs?! What?

I have been dipping my toes into Emacs again after realizing the unparalleled power of org-mode. Turns out it was a plugin I recently added to Emacs called org-trello that listens on the same port. Specifically org-trello uses elnode which listes on that port. So I disabled org-trello for now (just trialing it currently anyway) until I have time to figure out how to change the port that org-trello listens on. The bottom of the org-trello migrations page is promising, but my Emacs-fu is not up to snuff.

This took me longer than I expected to take on it. I think one of the issues is that Karma does not complain if something else is listening on the same port. I figured it was a problem with PhantomJS instead.

After this change, Karma was back and working again. Hope this shows how I think about debugging problems like this.

Blog Changes Afoot

Hey there, loyal blog reader! I wanted to tell you about some exciting changes that I have in the works for my blog. And, no, this is not Our Incredible Journey. :)

Domain change

My blog was previously called “22 Idea Street”. This was a name I mostly arbitrarily chose in 2008. Back in 2012, a movie called “21 Jump Street” was released, followed by a sequel “22 Jump Street”. Based on the similarity to these movies, and the arbitrariness of the name, I am deciding to rebrand the blog’s domain to avoid any confusion or unwanted connection. I have never seen the movies and have no idea what they are about. :) I was kind of bummed when I saw this and got less excited about writing here.

“panozzaj” has been my mostly standard username across various sites, and dates back to my days as a Rose-Hulman student. (Their naming convention for usernames was “first six of last name, first initial, middle initial”.) So as of today the blog will be available at panozzaj.com. I’ll slowly work on changing the site look and feel, but it works for now. Your existing RSS feeds should automatically redirect, and the email list should work the same as before.

Email format change

Previously, I sent the entire article of every new blog post to every person on this mailing list. This has caused me to be hesitant in what I publish to the blog because I have a high bar for emailing people. I want my blog to be a place where I can write down the things that I am learning and my new thoughts-in-progress, and not always need to be “the best article ever written, ever"™.

So instead of me posting all new posts from my blog straight to email, I’m going to curate the posts that I have and send out the best posts and summary posts that link to the site itself. This way, email subscribers can get my best material without needing to see the sausage being made.

If you still want to follow every post I make–from debugging Node.js internals, to playing with Android, to entrepreneurial thoughts and experiments, to robots and Vim internals–subscribe to the RSS feed. That isn’t going away any time soon, and you can always just quickly skip past posts that don’t interest you. If you still want all posts by email, let me know and I can set this up and make it more widely known.

Thanks for tuning in, and I’m excited to write a bit more freely with these blockers out of the way.

Trivia, Social Connection, and Meta-Information

Attention conservation notice: development of the idea that trivia and current events have value as a way to connect with people, and connecting this with the Covey model of tasks.

I attempt to eschew trivia, to avoid learning things that have little value. By definition, trivia is trivial, so it is desirable to know as little of it as possible. Anything that I have knowledge of that is not useful represents an opportunity cost of foregone useful knowledge. Perhaps winning trivia night should be considered a mark of shame.

I don’t really keep up with the news all that much. Most things are outside of my locus of control. Does it really matter what celebrity did something, or that a tornado just hit a midwest town? Tornadoes will be hitting towns and celebrities will be doing things until the world ends. But knowing this fact allows me to mostly safely abstract away the news. Every now and then I don’t hear about something, but then people are able to fill me in on the details. Following news on a daily, or worse, hourly, basis is a recipe for wasting time and getting little value.

But I think there are times when knowing relatively useless things can be useful. When you know every word to R. Kelly’s Remix to Ignition, or all of the state capitals, or what happened in a small town in Siberia, it can be a way to connect with other people. I think with division of labor there can be a disconnect between the things that we do during the majority of our lives. Trivia and current events are one way of understanding what goes on in the lives of most of the rest of the world. So this is something to keep in mind.

Obviously there are the incidental benefits of having some background knowledge on broader topics. Thinking of knowledge might be similar to tasks in the Covey model. Covey classifies tasks as a 2x2 matrix of valuable / not valuable, and urgent / non-urgent:

Covey's model

We may think of knowledge in the same terms. Seeking to acquire only as much urgent information as is necessary, and trying to lean toward useful information as much as possible. Avoiding non-urgent and non-useful information at all costs. This seems like a good heuristic for evaluting knowledge and the opportunity cost.

I suppose some sort of meta-news would be useful. Various magazines and articles purport to do this, but are typically biased on some way. Basically I just want relatively unadorned and important facts that are presented when a subject is stable enough to write in detail about.

Turning Away From Ruminations

There are some thoughts that are negative and self-reinforcing, and it is useful to catch these and stop thinking about them. A few years ago I shared my thoughts and techniques with someone else and they found it valuable, so I am going to share it here.

My personal example was playing conversations in my head about or with a certain person. I would imagine them saying something and what my responses would be. The conversations would typically be of an argumentative nature. Sometimes the thoughts would arise from me doing something and wondering what the other person would think. I think it was my brain’s defense mechanisms trying to prepare me for conflict.

When I realize these kinds of conversations in my head, I try to see if they have value, and if not, to let them go. It is especially useful to realize when the “conversations” are unprompted, when I am not interacting or going to interact with the person. I’m not sure if the correct term is rumination, but that is the term that I internally use. Basically recurring thoughts or themes of thoughts.

A useful shortcut is saying: “Whenever I think about X, my head is not in the right shape and I need to get it better.” X could be an old job, a former relationship, or anything else that is not serving me to think about. Mere presence of X in my thought patterns is early warning that I am in a low or vulnerable state, and need to be vigilant.

There are times when it is valuable to think about undesirable past or future events. But it is best done with a clear head and an empty text editor, and then to be done with it unless some epiphany or major new event happens. In this way, I can get the benefits of learning from mistakes without continually revisiting them and wasting time and mental energy. There are some classes of thoughts that are wholly unproductive and feed on themselves, and so are best avoided. Awareness of them and their true nature weakens them and puts me back in control.

Attention Conservation Notices

I have followed Cosma Shalizi’s blog / site for a long time, and there is a wealth of information on various technical fields such as statistics, computer science, economics, psychology, and much more. Really, his notebooks are a good index of interesting things. Every time I look through it I see new references to dense readings. Cosma also publishes blog posts, and these are often centered around books (he likely reads more hard books in a year than most people do in a lifetime) and classes that he is teaching.

One of the things I like about his blog is that the articles are long but often have an Attention Conservation Notice at the top. This is a longer version of tl;dr (too long; didn’t read), a summary or editor’s note on what is important. Some of my favorites are “I have no taste” (when he is talking about “books to read while algae grow in your fur”) or “7800 words about the intricacies of [some specific controversy in a subset of some specific field]”.

I think that this is a useful way to deliver value without wasting your audience’s time. Readers can quickly ascertain whether the article is likely to give them value now or in the future. Authors can publish things without quite as much self-filtering. I’d like it if more sites did the same thing.