Skip to content

Commit

Permalink
handle http proxy error (For #32)
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Nov 22, 2015
1 parent dd8afe8 commit cd4cb63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ var proxy = httpProxy.createProxyServer({
xfwd: true
})

proxy.on('error', function (err, req, res) {
onError('[proxy error] ' + req.method + ' ' + req.url + ' ' + err.message)

if (!res.headersSent) {
res.writeHead(500, { 'content-type': 'application/json' })
}

res.end(JSON.stringify({ err: err.message }))
})

var secretKey, secretCert
try {
secretKey = fs.readFileSync(path.join(__dirname, '../secret/webtorrent.io.key'))
Expand Down

2 comments on commit cd4cb63

@watson
Copy link
Member

@watson watson commented on cd4cb63 Nov 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice find! - Someone should make it easier to find the source of unhanded error events 😞

@feross
Copy link
Member Author

@feross feross commented on cd4cb63 Nov 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just a line number of even file name would have helped!

Please sign in to comment.