Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created February 21, 2011 09:37
Show Gist options
  • Save indexzero/836860 to your computer and use it in GitHub Desktop.
Save indexzero/836860 to your computer and use it in GitHub Desktop.
Apparently creating a ton of http servers in the same process and doing a ton of reverse proxying makes nodejs mad at you.
$ cd /Nodejitsu/node-http-proxy
$ node --version
v0.4.1
$ vows test/*-test.js --spec
♢ node-http-proxy/forward-proxy
When using server created by httpProxy.createServer() with forwarding enabled with no latency and a valid target server
✓ should receive 'hello localhost'
When using server created by httpProxy.createServer() with forwarding enabled with no latency and without a valid forward server
✓ should receive 'hello localhost'
When the tests are over
✓ the servers should clean up
♢ node-http-proxy
When using server created by httpProxy.createServer() with no latency and without a valid target server
✓ should receive 500 responseCode
When using server created by httpProxy.createServer() with no latency and a valid target server
✗ should receive 'hello localhost'
» expected 'hello localhost',
got undefined (==) // helpers.js:35
When using server created by httpProxy.createServer() with latency and without a valid target server
✓ should receive 500 responseCode
When using server created by httpProxy.createServer() with latency and a valid target server
✗ should receive 'hello localhost'
» expected 'hello localhost',
got 'An error has occurred: {"stack":"Error: Parse Error\\n at Socket.ondata (http.js:1183:22)\\n at Socket._onReadable (net.js:654:27)\\n at IOWatcher.onReadable [as callback] (net.js:156:10)","message":"Parse Error","bytesParsed":0}' (==) // helpers.js:35
When the tests are over
✓ the servers should clean up
♢ node-http-proxy/proxy-table
When using server created by httpProxy.createServer() when passed a routing table an incoming request to bar.com
✗ should receive 'hello bar.com'
» expected 'hello bar.com',
got undefined (==) // helpers.js:35
When using server created by httpProxy.createServer() when passed a routing file an incoming request to bar.com
✗ should receive 'hello bar.com'
» expected 'hello bar.com',
got undefined (==) // helpers.js:35
When using server created by httpProxy.createServer() when passed a routing table an incoming request to unknown.com
✓ should receive 404 responseCode
When using server created by httpProxy.createServer() when passed a routing file an incoming request to unknown.com
✗ should receive 404 responseCode
TypeError: Cannot read property 'statusCode' of undefined
at Object.<anonymous> (/Users/Charlie/Nodejitsu/node-http-proxy/test/helpers.js:60:21)
at runTest (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows.js:95:26)
at EventEmitter.<anonymous> (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows.js:78:13)
at EventEmitter.emit (events.js:42:17)
at /usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows/context.js:28:47
at [object Object].callback (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows/context.js:42:29)
at ClientRequest.<anonymous> (/usr/local/lib/node/.npm/request/1.9.0/package/main.js:111:35)
at ClientRequest.emit (events.js:42:17)
at Socket.<anonymous> (http.js:1171:9)
at Socket.emit (events.js:42:17)
When using server created by httpProxy.createServer() when passed a routing table an incoming request to foo.com
✗ should receive 'hello foo.com'
» expected 'hello foo.com',
got 'An error has occurred: {"stack":"Error: Parse Error\\n at Socket.ondata (http.js:1183:22)\\n at Socket._onReadable (net.js:654:27)\\n at IOWatcher.onReadable [as callback] (net.js:156:10)","message":"Parse Error","bytesParsed":0}' (==) // helpers.js:35
When using server created by httpProxy.createServer() when passed a routing file an incoming request to foo.com
✗ should receive 'hello foo.com'
» expected 'hello foo.com',
got 'An error has occurred: {"stack":"Error: Parse Error\\n at Socket.ondata (http.js:1183:22)\\n at Socket._onReadable (net.js:654:27)\\n at IOWatcher.onReadable [as callback] (net.js:156:10)","message":"Parse Error","bytesParsed":0}' (==) // helpers.js:35
When using server created by httpProxy.createServer() when passed a routing file an incoming request to dynamic.com after the file has been modified
✓ should receive 'hello dynamic.com'
When using an instance of ProxyTable combined with HttpProxy directly an incoming request to bar.com
✗ should receive 'hello bar.com'
» expected 'hello bar.com',
got undefined (==) // helpers.js:35
When using an instance of ProxyTable combined with HttpProxy directly an incoming request to unknown.com
✗ should receive 404 responseCode
TypeError: Cannot read property 'statusCode' of undefined
at Object.<anonymous> (/Users/Charlie/Nodejitsu/node-http-proxy/test/helpers.js:60:21)
at runTest (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows.js:95:26)
at EventEmitter.<anonymous> (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows.js:78:13)
at EventEmitter.emit (events.js:42:17)
at /usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows/context.js:28:47
at [object Object].callback (/usr/local/lib/node/.npm/vows/0.5.6/package/lib/vows/context.js:42:29)
at ClientRequest.<anonymous> (/usr/local/lib/node/.npm/request/1.9.0/package/main.js:111:35)
at ClientRequest.emit (events.js:42:17)
at Socket.<anonymous> (http.js:1239:27)
at Socket.emit (events.js:42:17)
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'emit' of undefined
at Socket.<anonymous> (http.js:1171:9)
at Socket.emit (events.js:42:17)
at Array.<anonymous> (net.js:799:27)
at EventEmitter._tickCallback (node.js:108:26)
{
"message":"Parse Error",
"bytesParsed":0
"stack": [
"Error: Parse Error",
"at Socket.ondata (http.js:1183:22)",
"at Socket._onReadable (net.js:654:27)"
"IOWatcher.onReadable [as callback] (net.js:156:10)"
]
}
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'emit' of undefined
at Socket.<anonymous> (http.js:1171:9)
at Socket.emit (events.js:42:17)
at Array.<anonymous> (net.js:799:27)
at EventEmitter._tickCallback (node.js:108:26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment