Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error message and type on function invocation errors #247

Merged

Conversation

andrestoll
Copy link
Contributor

Error type, message and trace will be shown for function invocation errors. Also when happens for pre or post processing.

Examples for executor function response

  • Raising an exception in the function code:
{
  "errorType": "Error",
  "errorMessage": "Invocation error (running in series) with payload \"null\" - original error type: \"Exception\", original error message: \"Exception raised during execution.\", trace: \"  File \"/var/task/lambda_function.py\", line 9, in lambda_handler\n    raise Exception(\"Exception raised during execution.\")\n\"",
  "trace": [
    "Error: Invocation error (running in series) with payload \"null\" - original error type: \"Exception\", original error message: \"Exception raised during execution.\", trace: \"  File \"/var/task/lambda_function.py\", line 9, in lambda_handler",
    "    raise Exception(\"Exception raised during execution.\")",
    "\"",
    "    at handleLambdaInvocationError (/var/task/executor.js:177:11)",
    "    at runInSeries (/var/task/executor.js:160:13)",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "    at async module.exports.handler (/var/task/executor.js:66:19)"
  ]
}

original function response:

{
    "StatusCode": 200,
    "FunctionError": "Unhandled",
    "ExecutedVersion": "$LATEST"
    "Payload": {"errorMessage": "Exception raised during execution.", "errorType": "Exception", "requestId": "c99e0a50-3b11-4c1a-aa20-108339da181b", "stackTrace": ["  File \"/var/task/lambda_function.py\", line 9, in lambda_handler\n    raise Exception(\"Exception raised during execution.\")\n"]}
}
  • Timeout
{
  "errorType": "Error",
  "errorMessage": "Invocation error (running in series) with payload \"null\" - original error type: \"undefined\", original error message: \"2024-04-29T15:49:41.111Z 29faf2b8-bbed-49ed-8df8-31cfb63a73a5 Task timed out after 3.00 seconds\", trace: \"undefined\"",
  "trace": [
    "Error: Invocation error (running in series) with payload \"null\" - original error type: \"undefined\", original error message: \"2024-04-29T15:49:41.111Z 29faf2b8-bbed-49ed-8df8-31cfb63a73a5 Task timed out after 3.00 seconds\", trace: \"undefined\"",
    "    at handleLambdaInvocationError (/var/task/executor.js:177:11)",
    "    at runInSeries (/var/task/executor.js:160:13)",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "    at async module.exports.handler (/var/task/executor.js:66:19)"
  ]
}

original func response:

{
    "StatusCode": 200,
    "FunctionError": "Unhandled",
    "ExecutedVersion": "$LATEST"
    "Payload": {"errorMessage":"2024-04-29T15:53:04.314Z 9fb99af1-d955-4c09-9e72-8e70756c327f Task timed out after 3.01 seconds"}
}

lambda/executor.js Outdated Show resolved Hide resolved
Copy link
Owner

@alexcasalboni alexcasalboni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 🚀 just a couple of minor comments/improvements

lambda/utils.js Outdated Show resolved Hide resolved
@@ -174,6 +166,16 @@ const runInSeries = async({num, lambdaARN, lambdaAlias, payloads, preARN, postAR
return results;
};

const handleLambdaInvocationError = (invocationResults, invocationMode, actualPayload, disablePayloadLogs) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like we could centralize this into utils.js, so it can be reused in utils.invokeLambdaProcessor as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@alexcasalboni alexcasalboni merged commit 6e91082 into alexcasalboni:master May 2, 2024
2 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants