Random crashes while running jsreport in azure virtual machine.

66 views
Skip to first unread message

ehealt...@gmail.com

unread,
Mar 16, 2017, 1:18:35 PM3/16/17
to jsreport
Occasionally while I am running jsreport in an azure VM, the server will crash and need to be restarted. The following is logged in my C:\Program Files\nodejs\logs\error.log file : 




2017-03-08T20:40:20.041Z - error: uncaughtException: Cannot read property 'split' of undefined date=Wed Mar 08 2017 20:40:20 GMT+0000 (Coordinated Universal Time), pid=2604, uid=null, gid=null, cwd=C:\Program Files\nodejs, execPath=C:\Program Files\nodejs\node.exe, version=v6.1.0, argv=[C:\Program Files\nodejs\node.exe, C:\Program Files\nodejs\server.js], rss=69636096, heapTotal=51425280, heapUsed=43294544, loadavg=[0, 0, 0], uptime=69891.2588031, trace=[column=50, file=Files\nodejs\node_modules\jsreport-express\lib\reporter.express.js, function=Server.<anonymous> (C:\Program, line=57, method=<anonymous> (C:\Program, native=false, column=13, file=events.js, function=emitTwo, line=106, method=null, native=false, column=7, file=events.js, function=Server.emit, line=191, method=emit, native=false, column=12, file=_http_server.js, function=HTTPParser.parserOnIncoming [as onIncoming], line=543, method=parserOnIncoming [as onIncoming], native=false, column=23, file=_http_common.js, function=HTTPParser.parserOnHeadersComplete, line=105, method=parserOnHeadersComplete, native=false], stack=[TypeError: Cannot read property 'split' of undefined,     at Server.<anonymous> (C:\Program Files\nodejs\node_modules\jsreport-express\lib\reporter.express.js:57:50),     at emitTwo (events.js:106:13),     at Server.emit (events.js:191:7),     at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12),     at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)]


Taking a look at reporter.express.js line 57 I see:

  // http and https port specified
  // fist start http => https redirector
  if (config.httpPort) {
    http.createServer(function (req, res) {
      res.writeHead(302, {
        'Location': 'https://' + req.headers.host.split(':')[0] + ':' + config.httpsPort + req.url   // Crashes here
      })
      res.end()
    }).listen(config.httpPort, reporter.options.hostname).on('error', function (e) {
      console.error('Error when starting http server on port ' + config.httpPort + ' ' + e.stack)
    })
  }


I am not sure why the host header would be undefined but I thought maybe someone here could point me in a general direction. Thanks

Boris Matos Morillo

unread,
Mar 16, 2017, 2:08:35 PM3/16/17
to jsreport, ehealt...@gmail.com
hmm are you using some kind of proxy in azure? req.headers.host will be undefined only if you are running jsreport behind a proxy, if you are using a proxy in which https is handled you should only set `httpPort` in your jsreport config not `httpsPort` at the same time. just to confirm if you are using a proxy you can try to console.log(req.headers['X-Forwarded-Host']) and see if you get some value. 
Reply all
Reply to author
Forward
0 new messages