Emulate AWS λ and API Gateway locally when developing your Serverless project
## Bug Report The python lambda times out if an unhandled error occurs (for example a runtime exception), the expected behaviour is to terminate the funtion and when the lambda is invoked to populate the `FunctionError` of the response with the error. However no information about the unhandled error is shown and the lambda continues to execute until a timeout. After some digging the problems seems to come from the `invoke.py` file in `src/lambda/handler-runner/python-runner`. Another thing to consider is that if an error occur during the imports (before the handler lambda is invoked) this also results in a time out, but should yield an error send again to the `FunctionError`. **Current Behavior** The python lambda times out if an unhandled error occurs instead of terminating. **Sample Code** ``` from aws_lambda_typing import context, events raise Exception("Random exception occurs") def handler(event: events.EventBridgeEvent, _ctx: context.Context): ... ``` - file: serverless.yml ```yaml service: my-service plugins: - serverless-python-requirements - serverless-plugin-ifelse - serverless-prune-plugin - serverless-offline provider: runtime: python3.11 stage: dev functions: factors: handler: src.handlers.factors.handler timeout: 29 ``` **Expected behavior/code** After encountering unhandled exception the lambda should be terminated and immediate response should be returned with the error encountered. **Environment** - `serverless` version: v3.39.0 - `serverless-offline` version: v14.0.0 - `python` version: v3.11 - `OS`: macOS 14.6.1 **Possible Solution** Use a try-except block to handle the error that is thrown and return the information using the `sys.stdout.write()` with argument which contains `__offline_payload__` with information about the error as JSON and `status_code` set to 500 for example. **Additional context/Screenshots** <!-- Add any other context about the problem here. If applicable, add screenshots to help explain. -->
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by ynaydenov-qb and has received 0 comments.