bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

[SUP-1281] AWS Lambda example app

Open luke-belton opened this issue 4 years ago • 5 comments

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:

  • Handled exceptions (with Bugsnag.notify)
  • Unhandled exceptions
  • Lambda timeouts
  • Promise rejections

Demonstrates Bugsnag's support for both async and callback Lambda handlers.

Changeset

Example app has been added within the /examples/aws-lambda/simple-app directory

Testing

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.

luke-belton avatar Aug 19 '21 16:08 luke-belton

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 43.13 kB 13.19 kB
After 43.13 kB 13.19 kB
± No change No change

code coverage diff

Coverage values did not change👌.

Total:

Lines Branches Functions Statements
0%(+0%) 0%(+0%) 0%(+0%) 0%(+0%)

Generated by :no_entry_sign: dangerJS against dd3c0f16ae47f6f97f2a629b0681fcae9bd7ff31

github-actions[bot] avatar Aug 19 '21 16:08 github-actions[bot]

Functionality works as expected for both local and deployed set ups.

I would suggest adding a bit more to the readme: Perhaps listing out each function endpoint with a little description of what it does.

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.

johnkiely1 avatar Mar 03 '22 17:03 johnkiely1

I would suggest adding a bit more to the readme

I've updated the readme to give a better description of the functions

The retuned {"message":"Internal server error"} for the majority of the endpoints was a little unexpected

I don't think there's much we can do about this as it's the way the function fails.

Errors do display the missing-sourcemaps banner on the dashboard

I can't find a way to generate sourcemaps with sam build. I think we'd need to look use something like webpack to build the functions if we wanted to generate sourcemaps

luke-belton avatar Mar 11 '22 15:03 luke-belton

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.

himanshufize avatar Jun 20 '22 17:06 himanshufize

@johnkiely1 - I haven't been able to repro the error Invalid lambda response received: Invalid API Gateway Response Keys:. Do you know what version of node you were running to test this?

Other than that I've pushed some changes that cover the rest of your comments I hope!

luke-belton avatar Sep 08 '22 16:09 luke-belton