Skip to content

Commit

Permalink
fix(core): Add guard against scope.getAttachments (#6258)
Browse files Browse the repository at this point in the history
We need to check for the existence of `finalScope.getAttachments` because `getAttachments` can be undefined if users are using an older version of `@sentry/core` that does not have the `getAttachments` method.
  • Loading branch information
AbhiPrasad committed Nov 22, 2022
1 parent 955a1b2 commit 74810e0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/baseclient.ts
Expand Up @@ -437,7 +437,12 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {

// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
if (finalScope) {
//
// We need to check for the existence of `finalScope.getAttachments`
// because `getAttachments` can be undefined if users are using an older version
// of `@sentry/core` that does not have the `getAttachments` method.
// See: https://github.com/getsentry/sentry-javascript/issues/5229
if (finalScope && finalScope.getAttachments) {
// Collect attachments from the hint and scope
const attachments = [...(hint.attachments || []), ...finalScope.getAttachments()];

Expand Down

0 comments on commit 74810e0

Please sign in to comment.