dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.72k stars 166 forks source link

TypeError: Cannot read property 'toString' of null Error on AWS SAM local, polkajs, & sapper #119

Closed btakita closed 4 years ago

btakita commented 5 years ago

I'm getting the following error in the SAM local environment:

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read property 'toString' of null",
    "stack": [
        "TypeError: Cannot read property 'toString' of null",
        "    at Object.keys.reduce (/var/task/node_modules/serverless-http/lib/provider/aws/sanitize-headers.js:18:27)",
        "    at Array.reduce (<anonymous>)",
        "    at sanitizeHeaders (/var/task/node_modules/serverless-http/lib/provider/aws/sanitize-headers.js:6:31)",
        "    at module.exports (/var/task/node_modules/serverless-http/lib/provider/aws/format-response.js:9:19)",
        "    at Runtime.handler (/var/task/node_modules/serverless-http/lib/provider/aws/index.js:13:12)",
        "    at process._tickCallback (internal/process/next_tick.js:68:7)"
    ]
}
btakita commented 5 years ago

To reproduce I used:

curl 'http://localhost:3000/favicon.ico' -H 'Pragma: no-cache' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36' -H 'Accept: image/webp,image/apng,image/*,*/*;q=0.8' -H 'Referer: http://localhost:3000/' -H 'Cookie: connect.sid=s%3AaSVtssIhhz1hIvPOBIgVIl7tIT7M5CpQ.ICPoqy4EMwRBjJX%2Ft3ozfjCLon0PGrCLn%2BrrBxd4PIA' -H 'Connection: keep-alive' -H 'Cache-Control: no-cache' --compressed