callback called two times on error
paolini opened this issue · 2 comments
serverless-crud/todos-read-all.js
Line 13 in 8096b82
when dynamoDb.scan gives an error, both callback(error) and callback(error, data.Items) get called.
In my case the database is giving an error (AccessDeniedError) and since data is null the code breaks in data.Items and the error is hidden.
I think that a return statement must be added in the if(error) case.
If I can add a question (this is my first experience with aws lambda) why is that when callback(error) gets called with a non empty error, the error gets logged but the user making the request is getting an empty response (I would expect an error response also there per http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-mode-exceptions.html )
PR #7 addresses this.