Commit 2ba11290 authored by Aral Balkan's avatar Aral Balkan

Highlight odd error where response duration is NaN

parent 4f2d58e5
......@@ -192,6 +192,7 @@ class Site {
// Logging.
this.app.use(morgan(function (tokens, req, res) {
let hasWarning = false
let hasError = false
let method = tokens.method(req, res)
if (method === 'GET') method = '↓ GET'
......@@ -207,6 +208,18 @@ class Site {
duration = `${duration} ms${clr(durationWarning, 'yellow')}`
if (duration === 'NaN ms') {
//
// I’ve only encountered this once (in response to what seems to
// be a client-side issue with Firefox on Linux possibly related to
// server-sent events:
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=1077089)
//
duration = ' - !'
hasError = true
}
let sizeWarning = ''
let size = (tokens.res(req, res, 'content-length')/1024).toFixed(1)
if (size > 500) { sizeWarning = ' !' }
......@@ -246,7 +259,8 @@ class Site {
}
let textColour = statusToTextColour[status]
if (hasWarning) { textColour = 'yellow'}
if (hasWarning) { textColour = 'yellow' }
if (hasError) { textColour = 'red' }
const log = [
clr(method, textColour),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment