lukeed / sirv

An optimized middleware & CLI application for serving static files~!
MIT License
1.07k stars 58 forks source link

Cannot set property 'statusCode' of undefined #30

Closed frederikhors closed 5 years ago

frederikhors commented 5 years ago

Many times when I open my browser waiting for the sirv server to start it gives an error like this in console:

rollup v1.14.4
bundles src/main.js → dist...
LiveReload enabled
C:\project\node_modules\sirv-cli\boot.js:40
                opts.onNoMatch = (req, res) => (req.path='/',fn(req, res, r => (r.statusCode=404,r.end())));
                                                                                            ^

TypeError: Cannot set property 'statusCode' of undefined
    at r (C:\project\node_modules\sirv-cli\boot.js:40:79)
    at C:\project\node_modules\sirv\index.js:93:18
    at opts.onNoMatch (C:\project\node_modules\sirv-cli\boot.js:40:48)
    at Server.<anonymous> (C:\project\node_modules\sirv\index.js:93:27)
    at Server.emit (events.js:203:15)
    at parserOnIncoming (_http_server.js:677:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)

I'm using sveltejs/template (rollup one)

and running from a package.json script like this:

"start:dev": "sirv dist --dev -s".

If I close my browser page and try to re-run everything works again!

lukeed commented 5 years ago

Do you have latest version installed?

frederikhors commented 5 years ago

"sirv-cli": "0.4.3"

lukeed commented 5 years ago

Yeah, I see the problem. I already fixed this But forgot it was in the next branch. That's why I asked, sorry

How fast track it for master fix

lukeed commented 5 years ago

Nevermind, the actual fix was much simpler so only needed to patch that part :)