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

[ROAD-756] AWS Lambda support #1334

Merged
merged 68 commits into from
Mar 16, 2021
Merged

[ROAD-756] AWS Lambda support #1334

merged 68 commits into from
Mar 16, 2021

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented Mar 11, 2021

This is the integration branch for all of the work that has gone into the support for Node.js on AWS Lambda.

I'm creating this PR to cut a prerelease and collect any UAT feedback.

This will:

1. Pack all relevant Bugsnag packages
2. Install them into any fixtures in `features/fixtures`
3. Build each fixture
4. Tidy up after itself
This stops a ruby backtrace from showing, which can be confusing -
the error happened in the 'build-fixtures' script rather than env.rb
Add Maze Runner scaffolding for Lambda tests
This monkey-patches the given client to keep track of the number of
in-flight requests and allows waiting until all requests have
finished (with a timeout)
This should never cause issues as the ES spec guarantees promises
that are resolved/rejected can't be resolved or rejected again,
however this is such a small change and is a bit more complete/safe
Create @bugsnag/in-flight internal package
in-flight: track requests when delivery is changed
Our existing plugin-app-duration doesn't report the correct duration
for Lambda functions because its 'appStart' is cached between
invocations. This means the duration would essentially be the Lambda
uptime, rather than the invocation time

We now calculate the duration in the wrapped handler, which ensures
it's fresh for each invocation
Session support for AWS Lambda functions
imjoehaines and others added 15 commits March 4, 2021 09:47
We can never be 100% sure that a timeout will happen because we need
to notify with enough time for the event to be delivered. Therefore
this is a best effort with a generous default value (1000ms) that
errs on the side of delivering the warning at the cost of possible
false positives

The default value can be changed by providing "lambdaTimeoutNotifyMs"
to createHandler. This is useful in cases where the lambda function
is very quick to execute and so can have a very short timeout without
necessarily being at risk of timing out

If set to "0" we don't bother adding the warning at all. This is
largely arbitrary as a value of 0 would never be triggered (because
the lambda would timeout at the same time)
Handle promise rejections in AWS Lambda functions
There's no point adding the timeout at all if it's too big as it
will never trigger
This is already handled by the 'super' call
Automatically notify when a lambda may timeout
This change prevents multiple sessions from being started if separate
plugins both call 'startSession' by making 'resumeSession' do nothing
if a session already exists
Avoid starting a session if one already exists
…ests

MazeRunner tests for serverless-express
CI doesn't have an up-to-date bundler version, but it's not really
worth updating as we have a single pinned dependency (so it's
essentially locked even without a lockfile)
@github-actions
Copy link

github-actions bot commented Mar 11, 2021

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.76 kB 12.57 kB
After 40.85 kB 12.61 kB
± ⚠️ +85 bytes ⚠️ +42 bytes

code coverage diff

Ok File Lines Branches Functions Statements
/home/runner/work/bugsnag-js/bugsnag-js/packages/in-flight/src/in-flight.js 100%
(+100%)
83.33%
(+83.33%)
100%
(+100%)
100%
(+100%)
/home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-aws-lambda/src/index.js 94.64%
(+94.64%)
94.29%
(+94.29%)
90.91%
(+90.91%)
94.64%
(+94.64%)
/home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-aws-lambda/src/lambda-timeout-approaching.js 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-browser-session/session.js 95.24%
(-4.76%)
87.5%
(-12.5%)
100%
(+0%)
95.24%
(-4.76%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-node-unhandled-rejection/unhandled-rejection.js 92.31%
(-7.69%)
87.5%
(-12.5%)
100%
(+0%)
93.33%
(-6.67%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-server-session/session.js 75%
(-1.09%)
50%
(+0%)
66.67%
(+0%)
71.15%
(-0.85%)

Total:

Lines Branches Functions Statements
81.47%(+0.51%) 70.32%(+0.51%) 84.01%(+0.47%) 80.38%(+0.51%)

Generated by 🚫 dangerJS against 4347759

This will now strip the version from 'bugsnag-core-7.9.0-alpha.0.tgz'
for example
Allow regex to match pre-release version numbers
@bengourley bengourley marked this pull request as ready for review March 15, 2021 15:46
Copy link
Contributor Author

@bengourley bengourley left a comment

Choose a reason for hiding this comment

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

Done with UAT. All working as expected 👍

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.

2 participants