Skip to content

Instantly share code, notes, and snippets.

@al6x
Created July 15, 2012 01:47
Show Gist options
  • Save al6x/3114352 to your computer and use it in GitHub Desktop.
Save al6x/3114352 to your computer and use it in GitHub Desktop.
Sample of strange nodejs error
// Starting server returning 'okay' to everyone.
require('http').createServer(function(req, res){
process.nextTick(function(){
res.end('okay')
})
}).listen(3000)
// Calling server.
var data = []
var opts = {host: 'localhost', port: 3000, path: '/', method: 'get'}
var req = require('http').request(opts, function(res){
res.on('data', function(chunk){data.push(chunk)})
res.on('end', function(){console.log(data.join())})
})
req.on('error', function(err){console.log(err)})
req.write("hello")
req.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment