Meteor 0.7.1.1 crashes when request comes from an undefined host #1871

Closed
jingidy opened this Issue Feb 26, 2014 · 10 comments

Projects

None yet

6 participants

@jingidy
jingidy commented Feb 26, 2014

When meteor receives a request with an undefined host in the header, it crashes under node inside http-proxy.

Reproduction recipe: https://github.com/jingidy/meteor-0.7.1.1-crash-host

Reproduces on 0.7.1.1
Does not reproduce on 0.7.0.1

Backtrace:

/Users/jingidy/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/common.js:78
  var res = req.headers.host.match(/:(\d+)/);
                             ^
TypeError: Cannot call method 'match' of undefined
    at Object.common.getPort (/Users/jingidy/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/common.js:78:30)
    at Array.XHeaders [as 2] (/Users/jingidy/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:68:21)
    at ProxyServer.<anonymous> (/Users/jingidy/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/index.js:83:21)
    at _.extend._tryHandleConnections (/Users/jingidy/.meteor/tools/8d9edffd4f/tools/run-proxy.js:169:20)
    at Server.<anonymous> (/Users/jingidy/.meteor/tools/8d9edffd4f/tools/run-proxy.js:48:12)
    at Server.EventEmitter.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2108:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at Socket.socket.ondata (http.js:1966:22)
    at TCP.onread (net.js:525:27)
@crsssl
crsssl commented Feb 27, 2014

I'm getting this one, too. Line-for-line the same error.

/Users/clivadas1/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/common.js:78
  var res = req.headers.host.match(/:(\d+)/);
                             ^
TypeError: Cannot call method 'match' of undefined
  at Object.common.getPort (/Users/clivadas1/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/common.js:78:30)
  at Array.XHeaders [as 2] (/Users/clivadas1/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:68:21)
  at ProxyServer.<anonymous> (/Users/clivadas1/.meteor/tools/8d9edffd4f/lib/node_modules/http-proxy/lib/http-proxy/index.js:83:21)
  at [object Object]._.extend._tryHandleConnections (/Users/clivadas1/.meteor/tools/8d9edffd4f/tools/run-proxy.js:169:20)
  at Server.<anonymous> (/Users/clivadas1/.meteor/tools/8d9edffd4f/tools/run-proxy.js:48:12)
  at Server.EventEmitter.emit (events.js:98:17)
  at HTTPParser.parser.onIncoming (http.js:2108:12)
  at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
  at Socket.socket.ondata (http.js:1966:22)
  at TCP.onread (net.js:525:27)
@glasser
Member
glasser commented Feb 27, 2014
@glasser
Member
glasser commented Feb 27, 2014

This should only affect the dev-mode runner, not production servers.

@crsssl
crsssl commented Feb 27, 2014

Thanks, David. Hope you're right.
The server actually crashed, and not very gracefully either. Hate to think what might happen at or on our production box..

@emgee3
Contributor
emgee3 commented Feb 27, 2014

I tested a server I have in production and can confirm that this does not cause the server to crash.

@pfafman
pfafman commented Mar 1, 2014

FYI: I have seen this crash on one of my sites run with the --production flag but not on another.

meteor run --port 80 --production

Regardless this probably needs to get fixed... '-)
Will try to also send this to the http-proxy repo, if I can find it.

/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/http-proxy/lib/http-proxy/common.js:78
  var res = req.headers.host.match(/:(\d+)/);
                             ^
TypeError: Cannot call method 'match' of undefined
  at Object.common.getPort (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/http-proxy/lib/http-proxy/common.js:78:30)
  at Array.XHeaders [as 2] (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:68:21)
  at ProxyServer.<anonymous> (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/http-proxy/lib/http-proxy/index.js:83:21)
  at [object Object]._.extend._tryHandleConnections (/home/ubuntu/.meteor/tools/f3947a4651/tools/run-proxy.js:169:20)
  at [object Object]._.extend.setMode (/home/ubuntu/.meteor/tools/f3947a4651/tools/run-proxy.js:196:10)
  at [object Object].AppProcess.onListen (/home/ubuntu/.meteor/tools/f3947a4651/tools/run-app.js:459:20)
  at Transformer.ondata (/home/ubuntu/.meteor/tools/f3947a4651/tools/run-app.js:93:31)
  at next (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/eachline/eachline.js:135:18)
  at signaled (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/eachline/eachline.js:129:5)
  at next (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/eachline/eachline.js:141:4)
  at Transformer._transform (/home/ubuntu/.meteor/tools/f3947a4651/lib/node_modules/eachline/eachline.js:158:2)
  at Transformer.Transform._read (_stream_transform.js:179:10)
  at Transformer.Transform._write (_stream_transform.js:167:12)
  at doWrite (_stream_writable.js:223:10)
  at writeOrBuffer (_stream_writable.js:213:5)
  at Transformer.Writable.write (_stream_writable.js:180:11)
  at write (_stream_readable.js:583:24)
  at flow (_stream_readable.js:592:7)
  at Socket.pipeOnReadable (_stream_readable.js:624:5)
  at Socket.EventEmitter.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:408:10)
  at emitReadable (_stream_readable.js:404:5)
  at readableAddChunk (_stream_readable.js:165:9)
  at Socket.Readable.push (_stream_readable.js:127:10)
  at Pipe.onread (net.js:526:21)

thanks,
Tim

@emgee3
Contributor
emgee3 commented Mar 1, 2014

I'm not suggesting the bug should go unfixed, but running meteor run --production flag isn't the same thing as meteor deploy --- or meteor bundle --- and then running the generated bundle.

Perhaps this ought to be made more clear in the documentation, meteor run --production is still running as a development server, except concatenation and minification is done. The server still restarts when files are changed, for example.

In development mode there are a few javascript files collectively referred to as runner which use the http-proxy package from npm (see https://github.com/meteor/meteor/blob/devel/tools/run-proxy.js#L36 ) which to my knowledge are not used with a meteor deploy or deploying a bundle.

@glasser glasser closed this in 0791b31 Mar 4, 2014
@glasser
Member
glasser commented Mar 4, 2014

Fixed on devel.

@SkeLLLa
SkeLLLa commented Mar 13, 2014

Nodejitsu have finally merged my pull request into master, so now this should not crash.

@glasser
Member
glasser commented Mar 13, 2014

@SkeLLLa Yeah, I didn't want to wait, so I fixed (the devel branch of meteor) to use a fork with your PR last week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment