-
Notifications
You must be signed in to change notification settings - Fork 253
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
[SUP-1281] AWS Lambda example app #1517
base: next
Are you sure you want to change the base?
Conversation
Functionality works as expected for both local and deployed set ups. I would suggest adding a bit more to the readme: The retuned {"message":"Internal server error"} for the majority of the endpoints was a little unexpected. I think this is a consequence of the way the lambda function fails. It would be nice if this could be something a little less vague or at least reference it in the readme that this would be expected. There is a open question/potential bug with platforms regarding caching behaviour for surrounding code retrieval as the /async/handled-error and /callback/handled error can return incorrect code. But we could avoid this by either renaming one of the files or moving the notify away from line 12 on one of them. It's probably worth doing this anyway to avoid confusion. Errors do display the missing-sourcemaps banner on the dashboard. I wonder if it possible to get these to be produced with the build? if possible add some additional instructions in the readme on how to upload. |
I've updated the readme to give a better description of the functions
I don't think there's much we can do about this as it's the way the function fails.
I can't find a way to generate sourcemaps with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some failing tests which need to be looked at.
I've not been able to retest any errors arriving to the dashboard as I encounter multiple errors using a brand new copy of the repo and running the sam local
command
Firstly :
Invoking callback-handled-exception.lambdaHandler (nodejs14.x)
NodeDependenciesLayer is a local Layer in the template
Image was not found.
FileNotFoundError: [Errno 2] No such file or directory: '/Users/johnkiely/Documents/test_projects/testAwsExample/bugsnag-js/examples/aws-lambda/simple-app/callback-dependencies-layer'
I think this is solved by the following:
template.yaml -> change to ContentUri: dependencies-layer/
However then I get:
Invalid lambda response received: Invalid API Gateway Response Keys: {'errorType', 'trace', 'errorMessage'} in {'errorType': 'Runtime.ImportModuleError', 'errorMessage': "Error: Cannot find module '@bugsnag/js'\nRequire stack:\n- /var/task/async-handled-exception.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js", 'trace': ["Runtime.ImportModuleError: Error: Cannot find module '@bugsnag/js'", 'Require stack:', '- /var/task/async-handled-exception.js', '- /var/runtime/UserFunction.js', '- /var/runtime/Runtime.js', '- /var/runtime/index.js', ' at _loadUserApp (/var/runtime/UserFunction.js:221:13)', ' at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)', ' at Object. (/var/runtime/index.js:43:34)', ' at Module._compile (internal/modules/cjs/loader.js:1085:14)', ' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)', ' at Module.load (internal/modules/cjs/loader.js:950:32)', ' at Function.Module._load (internal/modules/cjs/loader.js:790:12)', ' at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)', ' at internal/main/run_main_module.js:17:47']}
Looks like something is broken with the dependency resolution.
Also I think we may want to consider not including the package-lock.json file. I was using npm 6 which gave warnings because lockfileVersion:2 is not supported. https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json#lockfileversion. Also npm 8 doesn't support lockfileVersion:1. So users may need to generate their own based on npm version as 6-8 are all currently widely used.
Typo's/suggestions in readme. see in line comments
I try to implement bugsnag for handled error but it not able to log error when I try to call notify inside catch block. I try block it doing it. |
@@ -0,0 +1,25 @@ | |||
const Bugsnag = require('@bugsnag/js') | |||
const BugsnagPluginAwsLambda = require('@bugsnag/plugin-aws-lambda') | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luke-belton Just one request. Can you add an example in which we call multiple functions and in those function error could occur but they should not break the flow of execution?
This in regard use case when failure in some place is OK but still be need log regarding those failures - One API request
@johnkiely1 - I haven't been able to repro the error Other than that I've pushed some changes that cover the rest of your comments I hope! |
Goal
Bugsnag has a plugin for AWS Lambda but until now there was no example app to demonstrate Bugsnag + AWS Lambda functionality.
Design
Adds Lambda functions to demonstrate the following:
Bugsnag.notify
)Demonstrates Bugsnag's support for both async and callback Lambda handlers.
Changeset
Example app has been added within the
/examples/aws-lambda/simple-app
directoryTesting
Tested all functions with
sam local run-api
and sam local invoke "<RESOURCE_NAME>" -e <path/to/event.json>. The functions have also been deployed to AWS and tested there too.Note that the timeout functions don't work locally due to a bug with AWS SAM CLI bug, but they work on the deployed test app.