Closed
Description
splitting out @waynehoover's issue from here: #43 (comment)
when you do this:
exports.handler = async function(event, context) {
let body = parse(event.body)
await doSomeAsyncWorkHere();
return {
statusCode: 301,
// oops no body
}
}
you get this:
(node:26997) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type undefined
at write_ (_http_outgoing.js:607:11)
at ServerResponse.write (_http_outgoing.js:579:10)
at callback (/Users/.../node_modules/netlify-lambda/lib/serve.js:26:14)
at /Users/.../node_modules/netlify-lambda/lib/serve.js:41:21
at process.internalTickCallback (internal/process/next_tick.js:77:7)
(node:26997) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26997) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hash: ec967454cf2cf833f214
we should basically insert an undefined check here: https://github.com/netlify/netlify-lambda/blob/master/lib/serve.js#L29 and serve a friendly warning
should also thinking about other forms of validation