addyosmani/tmi

Crash with no images

brycebaril opened this issue · 3 comments

$ tmi http://brycebaril.com

TypeError: Expected a number
    at prettyBytes (/usr/local/lib/node_modules/tmi/node_modules/pretty-bytes/pretty-bytes.js:18:10)
    at Object.exports.process (/usr/local/lib/node_modules/tmi/output.js:97:50)
    at /usr/local/lib/node_modules/tmi/index.js:27:12
    at /usr/local/lib/node_modules/tmi/node_modules/gpagespeed/index.js:24:12
    at Request._callback (/usr/local/lib/node_modules/tmi/node_modules/gpagespeed/node_modules/googleapis/lib/transporters.js:90:7)
    at Request.self.callback (/usr/local/lib/node_modules/tmi/node_modules/gpagespeed/node_modules/googleapis/node_modules/request/request.js:123:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/usr/local/lib/node_modules/tmi/node_modules/gpagespeed/node_modules/googleapis/node_modules/request/request.js:1047:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/tmi/node_modules/gpagespeed/node_modules/googleapis/node_modules/request/request.js:998:12)

I (foolishly) didn't account for pages without any images at all. Thanks for the report. I'll add better bail out handling around https://github.com/addyosmani/tmi/blob/master/output.js#L95 to account for no image weight numbers being returned.

I figured it was a pretty edge-case use of a tool specifically designed to report about images, but I figured you'd want to know about the crash :)

Clonsed by #5