Skip to content

ConcurrentModificationError when doing performance tracing #1256

Description

@ueman

Platform:

  • Dart
  • Flutter Android or iOS
  • Flutter Web

IDE:

  • VSCode
  • IntelliJ/AS
  • XCode
  • Other, which one?

split-debug-info and obfuscate (Flutter Android or iOS) or CanvasKit (Flutter Web):

  • Enabled
  • Disabled

Platform installed with:

  • pub.dev
  • GitHub

The version of the SDK (See pubspec.lock):
6.18.1 (but it's also happening on 6.19.0)


I have the following issue:

Sometimes when tracing performance, I see a ConcurrentModificationError. It is thrown by the following code:

await Future.forEach(
spansToBeFinished,
(SentrySpan span) async => await span.finish(
status: SpanStatus.deadlineExceeded(),
endTimestamp: commonEndTimestamp));

Unfortunately, I failed to create a minimal reproducible example. Therefore, I'm attaching some screenshots. The first one is the issue on Sentry.io itself, but unfortunately it's not helpful at all.

Screenshot 2023-01-31 at 12 34 30

The second one come from debugging the issue, to show that it's indeed coming from Sentry. Unfortunately, the stacktrace of that error is the same as the one above.
Screenshot 2023-01-31 at 12 34 56

I'm assuming that it's caused by unfinished spans somehow. Roughly, the code in the (closed source) app is the following:

methodOne() {
 transaction{
   awaited spans (3 times)
   one unawaited span
   awaited spans (4 times)
 }
}

during the same time as methodOne is a web request running, which also attaches a span to the above mentioned transaction

After the above transaction is finished, another one is started. I don't know whether that's related or not.

I would expect Sentry to not throw a ConcurrentModificationError.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions