Node.Js problem makes me want to kill myself


#1

Here is the error:

events.js:141
      throw er; // Unhandled 'error' event

I HAVE BEEN TRYING TO FIX THIS FOR HOURS!!!
And yes, I have googled the problem, but the solutions don’t seem to apply to cloud9

var http = require('http')
var bl = require('bl')
var results = []
var count = 0

function printResults () {
  for (var i = 0; i < 3; i++)
    console.log(results[i])
}

function httpGet (index) {
  http.get(process.argv[2 + index], function (response) {
    response.pipe(bl(function (err, data) {
      if (err)
        return console.error(err)

      results[index] = data.toString()
      count++

      if (count == 3)
        printResults()
    }))
  })
}

for (var i = 0; i < 3; i++)
  httpGet(i)

#2

but the solutions don’t seem to apply to cloud9

what do you mean? Your code is running on ubuntu vm, so any general solution would apply to cloud9


#3

Well, the problem according to everyone else on forums is that the same file is running somewhere else, but I’ve tried logging out, exiting everything else, and neither has worked…


#4

The error says it’s being caused by an unhandled error event, and that’s exactly what’s happening. http.get(). Look at the example in the Node docs for http.request(). You will need to handle events as it does there.

If you prefer something more high level then try using request instead.


#5

Hello,

I got this error catch it, and get EADDRINUSE 0.0.0.0:8080, then C9 proposed to kill the process, I did and then no more error