Function response should have empty body if async keyword is missing #1047
Labels
area: functions
good first issue
status: unconfirmed
type: bug
code to address defects in shipped code
- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
There is a difference in behaviour between local and production if you miss the
async
keyword in a lambda function. When runningnetlify dev
, the response body is output. However, on production, the body is empty. This is confusing, and the local behaviour should match production.- If the current behavior is a bug, please provide the steps to reproduce.
Using this function - note, it is missing the
async
keyword:When I run this locally using
netlify dev
, I seeHello world
output when I hit the local endpoint. However, when it is uploaded to the production environment, the function runs (theconsole.log
output is visible in the function log), but the response body is empty.- What is the expected behavior?
Local
netlify dev
should match the production behaviour, i.e. there should be no response body output from this function.(Note that if the first line is changed to add the
async
keyword, i.e.exports.handler = async function(event) {
, then both local and production behave the same - i.e. you do see the "Hello world" output in the body. Not sure why removing theasync
keyword results in this change in behaviour, as the function doesn't await anything, but this is a difference in observed behaviour between local and production environments, and it confused me for a while)- Local Environment Information
The text was updated successfully, but these errors were encountered: