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

Fix: Breadcrumbs "Concurrent Modification" #948

Merged
merged 10 commits into from Jul 21, 2022
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions dart/lib/src/scope.dart
Expand Up @@ -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);
}

Expand Down
14 changes: 7 additions & 7 deletions dart/test/sentry_client_test.dart
Expand Up @@ -553,12 +553,12 @@ void main() {
breadcrumbs: eventCrumbs,
);

Scope createScope(SentryOptions options) {
Future<Scope> 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;
}

Expand All @@ -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);

Expand All @@ -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'));

Expand All @@ -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(
Expand Down