diff --git a/CHANGELOG.md b/CHANGELOG.md index cf184ea1d..40c3622fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ ### Fixes * Maps with Key Object, Object would fail during serialization if not String, Object ([#935](https://github.com/getsentry/sentry-dart/pull/935)) -* Fix duplicative Screen size changed breadcrumbs ([#888](https://github.com/getsentry/sentry-dart/pull/888)) +* Breadcrumbs "Concurrent Modification" ([#948](https://github.com/getsentry/sentry-dart/pull/948)) +* Duplicative Screen size changed breadcrumbs ([#888](https://github.com/getsentry/sentry-dart/pull/888)) ### Features diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index e0a4fe090..0802975af 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -390,29 +390,29 @@ class Scope { await clone.setUser(user); - for (final tag in _tags.keys) { + for (final tag in List.from(_tags.keys)) { await clone.setTag(tag, _tags[tag]!); } - for (final extraKey in _extra.keys) { + for (final extraKey in List.from(_extra.keys)) { await clone.setExtra(extraKey, _extra[extraKey]); } - for (final breadcrumb in _breadcrumbs) { + for (final breadcrumb in List.from(_breadcrumbs)) { await clone.addBreadcrumb(breadcrumb); } - for (final eventProcessor in _eventProcessors) { + for (final eventProcessor in List.from(_eventProcessors)) { clone.addEventProcessor(eventProcessor); } - contexts.forEach((key, value) { - if (value != null) { - clone.setContexts(key, value); + for (final entry in Map.from(contexts).entries) { + if (entry.value != null) { + await clone.setContexts(entry.key, entry.value); } - }); + } - for (final attachment in _attachments) { + for (final attachment in List.from(_attachments)) { clone.addAttachment(attachment); } diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 8bd7c06b4..f0c1085f8 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -553,12 +553,12 @@ void main() { breadcrumbs: eventCrumbs, ); - Scope createScope(SentryOptions options) { + Future createScope(SentryOptions options) async { final scope = Scope(options) ..transaction = transaction - ..fingerprint = fingerprint - ..addBreadcrumb(crumb); - scope.setUser(user); + ..fingerprint = fingerprint; + await scope.addBreadcrumb(crumb); + await scope.setUser(user); return scope; } @@ -568,7 +568,7 @@ void main() { test('should not apply the scope to non null event fields ', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await client.captureEvent(event, scope: scope); @@ -585,7 +585,7 @@ void main() { test('should apply the scope user to null event user fields ', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await scope.setUser(SentryUser(id: '987')); @@ -608,7 +608,7 @@ void main() { test('merge scope user and event user extra', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await scope.setUser( SentryUser(