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

Clone clients in AWS Lambda session implementation when a server plugin is used #1887

Merged
merged 5 commits into from
Dec 9, 2022

Conversation

imjoehaines
Copy link
Contributor

Goal

This PR fixes a conflict between the AWS Lambda plugin and server plugins (Express, Koa & Restify) where the server plugins expect the session delegate to create a cloned client but the AWS Lambda session delegate doesn't do that

This is a bit more complicated than simply cloning the client in the AWS Lambda session delegate — doing so causes unexpected behaviour when not using a server plugin as the client created by Bugsnag.start would not have access to the session information and therefore session data doesn't get attributed to events properly

See #1875

When a server plugin (e.g. Express) is loaded, we need to clone the
client returned from `startSession` in order for them to behave as
expected

We can't unconditionally clone clients as this causes events and
sessions to be associated with different clients, breaking the link
between the two
@@ -83,5 +83,4 @@ Scenario: promise rejections are reported when using serverless-express
Then the session is valid for the session reporting API version "1" for the "Bugsnag Node" notifier
And the session "id" is not null
And the session "startedAt" is a timestamp
And the event "session.events.handled" equals 0
And the event "session.events.unhandled" equals 1
And the event "session.events" is null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This promise rejection isn't associated with a session anymore, because the session is started by the Express plugin in the request but an unhandled promise rejection is caught globally and therefore by a different client with no knowledge of the session

@github-actions
Copy link

github-actions bot commented Dec 8, 2022

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 43.19 kB 13.21 kB
After 43.19 kB 13.21 kB
± No change No change

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against 3d39854

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