gunnargrosch / failure-lambda

Module for fault injection into AWS Lambda
MIT License
94 stars 13 forks source link

Exception returns successfully #3

Open jpbarto opened 4 years ago

jpbarto commented 4 years ago

When setting 'failureMode' to 'exception' the Lambda function returns successfully, an exception occurs but the Lambda function succeeds.

START RequestId: 303ca17f-a63c-44ce-a38e-9236e3db57c2 Version: $LATEST
2020-02-07T14:18:14.839Z    303ca17f-a63c-44ce-a38e-9236e3db57c2    INFO    Injecting exception message: Exception message!
2020-02-07T14:18:14.852Z    303ca17f-a63c-44ce-a38e-9236e3db57c2    INFO    Error: Exception message!
    at Runtime.handler (/var/task/node_modules/failure-lambda/lib/failure.js:31:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)END RequestId: 303ca17f-a63c-44ce-a38e-9236e3db57c2
REPORT RequestId: 303ca17f-a63c-44ce-a38e-9236e3db57c2  Duration: 142.89 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 96 MB  

I would have expected a thrown exception to cause the Lambda function to fail.

gunnargrosch commented 4 years ago

Not throwing the exception is an oversight from my end in the rush to release on Christmas eve. It should of course do that. :)

So with that and your PR for catchException flag in mind, do you see any scenario when we don't want to throw the exception?

gunnargrosch commented 4 years ago

Merged part of the code to fix the issue with not throwing the exception and published a new version of the package. The question if we want catchException flag is still open.

jpbarto commented 4 years ago

@gunnargrosch my thinking was that there may be merit to wanting the Lambda function to exit with an error without necessarily reporting the error to Lambda. Putting potentially dangerous code inside a try / catch is very common in my experience - so I think it would be valuable to have as a feature.

gunnargrosch commented 4 years ago

@jpbarto Sounds good to me! To keep this as a minor update I would like the setting in the parameter to be optional. Would mean that users don't have change their parameters to use the new version. I guess that means a simple if statement by the newly added throw ex.