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

Discard empty stack frames #1625

Merged
merged 8 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Normalize data properties of `SentryUser` and `Breadcrumb` before sending over method channel ([#1591](https://github.com/getsentry/sentry-dart/pull/1591))
- Fixing memory leak issue in SentryFlutterPlugin (Android Plugin) ([#1588](https://github.com/getsentry/sentry-dart/pull/1588))
- Discard empty stack frames ([#1625](https://github.com/getsentry/sentry-dart/pull/1625))

### Dependencies

Expand Down
24 changes: 12 additions & 12 deletions dio/test/dio_event_processor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -96,7 +96,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -125,7 +125,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -177,7 +177,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -207,7 +207,7 @@ void main() {
data: 'foobar',
headers: Headers.fromMap(<String, List<String>>{
'foo': ['bar'],
'set-cookie': ['foo=bar']
'set-cookie': ['foo=bar'],
}),
requestOptions: request,
isRedirect: true,
Expand All @@ -219,7 +219,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -248,7 +248,7 @@ void main() {
response: Response<dynamic>(
data: 'foobar',
headers: Headers.fromMap(<String, List<String>>{
'foo': ['bar']
'foo': ['bar'],
}),
requestOptions: request,
isRedirect: true,
Expand All @@ -260,7 +260,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down Expand Up @@ -320,7 +320,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand All @@ -338,7 +338,7 @@ void main() {
final dataByType = {
ResponseType.plain: ['plain'],
ResponseType.bytes: [
[1337]
[1337],
],
ResponseType.json: [
9001,
Expand All @@ -347,7 +347,7 @@ void main() {
true,
['list'],
{'map-key': 'map-value'},
]
],
};

for (final entry in dataByType.entries) {
Expand Down Expand Up @@ -375,7 +375,7 @@ void main() {
throwable: throwable,
exceptions: [
fixture.sentryError(throwable),
fixture.sentryError(dioError)
fixture.sentryError(dioError),
],
);
final processedEvent = sut.apply(event) as SentryEvent;
Expand Down
2 changes: 1 addition & 1 deletion dio/test/failed_request_interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Fixture {

FailedRequestInterceptor getSut({
List<SentryStatusCode> failedRequestStatusCodes = const [
SentryStatusCode.defaultRange()
SentryStatusCode.defaultRange(),
],
List<String> failedRequestTargets = const ['.*'],
}) {
Expand Down
2 changes: 1 addition & 1 deletion dio/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final fakeEvent = SentryEvent(
type: 'navigation',
data: <String, dynamic>{'screen': 'MainActivity', 'state': 'created'},
level: SentryLevel.info,
)
),
],
contexts: Contexts(
operatingSystem: const SentryOperatingSystem(
Expand Down
7 changes: 5 additions & 2 deletions flutter/lib/src/jvm/jvm_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ class JvmException {
frames.add(trimmed);
}

final thisExceptionFrames =
thisException.map((e) => JvmFrame.parse(e)).toList(growable: false);
final thisExceptionFrames = thisException
.map((e) => JvmFrame.parse(e))
.where(
(e) => e.originalFrame.isNotEmpty && e.originalFrame.trim() != 'at')
.toList(growable: false);
denrase marked this conversation as resolved.
Show resolved Hide resolved

final suppressedExceptions = supressed
.map((e) => JvmException.parse(e.join(_newLine)))
Expand Down
30 changes: 29 additions & 1 deletion flutter/test/jvm/jvm_exception_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void main() {
'Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]');
expect(thirdCause.thread, null);
expect(thirdCause.type, 'java.sql.SQLException');
expect(thirdCause.stackTrace.length, 6);
expect(thirdCause.stackTrace.length, 5);
expect(thirdCause.causes, null);
expect(thirdCause.suppressed, null);
});
Expand Down Expand Up @@ -85,6 +85,16 @@ void main() {
expect(exception.stackTrace[0].fileName, 'StandardMessageCodec.java');
expect(exception.stackTrace[0].lineNumber, 292);
});

test('parse drops frames with `at ` and empty original frame', () {
final exception = JvmException.parse(platformExceptionWithEmptyStackFrames);
expect(exception.stackTrace.length, 13);
expect(exception.stackTrace.last.className,
'com.android.internal.os.ZygoteInit');
expect(exception.stackTrace.last.fileName, 'ZygoteInit.java');
expect(exception.stackTrace.last.method, 'main');
expect(exception.stackTrace.last.lineNumber, 936);
});
}

const javaExceptionWithCauses = '''
Expand Down Expand Up @@ -194,3 +204,21 @@ java.lang.IllegalArgumentException: Unsupported value: '[Ljava.lang.StackTraceEl
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit\$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1037)''';

const platformExceptionWithEmptyStackFrames = '''
java.lang.RuntimeException: Catch this platform exception!
at io.sentry.samples.flutter.MainActivity\$configureFlutterEngine\$1.onMethodCall(MainActivity.kt:40)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda\$dispatchMessageToQueue\$0\$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
at io.flutter.embedding.engine.dart.DartMessenger\$\$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit\$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
at
''';
denrase marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion sqflite/test/mocks/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ISentrySpan startTransactionShim(
DatabaseExecutor,
],
customMocks: [
MockSpec<Hub>(fallbackGenerators: {#startTransaction: startTransactionShim})
MockSpec<Hub>(
fallbackGenerators: {#startTransaction: startTransactionShim}),
],
)
void main() {}