Skip to content

Commit 74810e0

Browse files
authored
fix(core): Add guard against scope.getAttachments (#6258)
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.
1 parent 955a1b2 commit 74810e0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/core/src/baseclient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,12 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
437437

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

0 commit comments

Comments
 (0)