Closed blaugold closed 1 year ago
Thanks @blaugold , will test it out.
Image:
JSON event:
Uploaded bundle:
Bundles are actually here: https://sentry-sdks.sentry.io/settings/projects/sentry-flutter/source-maps/artifact-bundles/13d8dc56-b866-5275-8cb8-618012f1b6d5/
Either the generated source maps changed something or there's a regression in our system, I will check this internally.
The processing team is looking at this.
@loewenheim should we close this as done? re https://github.com/getsentry/symbolic/pull/786
Actually I meant to post the corrected stacktrace here for feedback, thanks for reminding me :)
With the linked symbolic change, we now get this stacktrace for the provided example program:
As you can see, most function names are now resolved, but we don't have source contents for all files.
@loewenheim is this deployed and live already? If so, @blaugold mind testing once more? Thanks!
It's not live yet, I'll get it ready ASAP
Closed this prematurely. The fix is now live.
Thanks for the swift fix! For synchronous code, I now get the correct function names. 🎉 Unfortunately, it does not solve the issue for async code. 😅
If you change the function that throws the exception to the code below, the throwing frame is reported like this: at $async$$0(../../../lib/main.dart:25:15)
.
onPressed: () async {
await Future(() {});
throw Exception('Test exception');
},
Here is an example of how the source_map_stack_trace
package can be used to unminify even async code:
import 'dart:convert';
import 'dart:io';
import 'package:source_map_stack_trace/source_map_stack_trace.dart';
import 'package:source_maps/source_maps.dart';
const stackTraceString = r'''
minified:GR: Exception: Test exception
at Object.b (main.dart.js:4293:3)
at <fn> (main.dart.js:56371:16)
at a45.a (main.dart.js:5603:62)
at a45.$2 (main.dart.js:31015:14)
at a2X.$1 (main.dart.js:31009:21)
at Object.a3Z (main.dart.js:5858:19)
at Ed.<fn> (main.dart.js:57768:68)
at Gh.jD (main.dart.js:31819:12)
at a0i.$0 (main.dart.js:31350:11)
at Object.p3 (main.dart.js:5729:40)
''';
void main() {
final mapping = SingleMapping.fromJson(jsonDecode(File('build/web/main.dart.js.map').readAsStringSync()));
final stackTrace = StackTrace.fromString(stackTraceString);
final mappedStackTrace = mapStackTrace(mapping, stackTrace, minified: true);
print(mappedStackTrace.toString());
}
And this is its output:
org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/js_helper.dart 1195:37 wrapException
../../../lib/main.dart 25:15 MainApp.build.<anonymous function>
org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart 306:19 _wrapJsFunctionForAsync
org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart 331:23 _wrapJsFunctionForAsync.<anonymous function>
org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart 282:19 _awaitOnObject.<anonymous function>
org-dartlang-sdk:///dart-sdk/lib/async/zone.dart 1407:46 _rootRunUnary
org-dartlang-sdk:///dart-sdk/lib/async/zone.dart 1405:3 _rootRunUnary[function-entry$5]
org-dartlang-sdk:///dart-sdk/lib/async/zone.dart 1307:34 _CustomZone.runUnary
org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart 112:29 _FutureListener.handleValue
org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart 813:13 _Future._propagateToListeners
Running the source map from the example through symbolic
I can see that a useful function name is available in the name
field of a source location.
#[test]
fn dart_debug() {
let minified = std::fs::read_to_string(fixture("sourcemapcache/dart/main.dart.js")).unwrap();
let map = std::fs::read_to_string(fixture("sourcemapcache/dart/main.dart.js.map")).unwrap();
let writer = SourceMapCacheWriter::new(&minified, &map).unwrap();
let mut buf = vec![];
writer.serialize(&mut buf).unwrap();
let cache = SourceMapCache::parse(&buf).unwrap();
let sl = cache.lookup(SourcePosition::new(56371, 16)).unwrap();
println!("{:?}", sl);
}
Compiling symbolic-sourcemapcache v12.1.5 (/Users/terwesten/dev/symbolic/symbolic-sourcemapcache)
Finished test [unoptimized + debuginfo] target(s) in 0.40s
Running tests/integration.rs (target/debug/deps/integration-9650d2080c26a134)
running 1 test
SourceLocation { file: Some(File { name: Some("../../../lib/main.dart"), source: None, line_offsets: [LineOffset(0)] }), line: 25, column: 13, name: Some("MainApp.build.<anonymous function>"), scope: NamedScope("$async$$0") }
test dart_debug ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out; finished in 1.91s
Would it be a problem to use the mapped name
for function names of Dart stack traces when available instead of scope
?
@loewenheim can you take a look at this use case as well?
Thanks @blaugold for debugging this with us. I've raised the issue https://github.com/getsentry/symbolic/issues/791 Let's track the linked issue there, closing this one since the original bug is resolved.
Continuing from here: https://github.com/getsentry/sentry-dart/issues/897#issuecomment-1539666926
Platform
Flutter Web
Obfuscation
Disabled
Debug Info
Disabled
Doctor
Flutter 3.7.12 • channel stable • https://github.com/flutter/flutter.git Framework • revision 4d9e56e694 (3 weeks ago) • 2023-04-17 21:47:46 -0400 Engine • revision 1a65d409c7 Tools • Dart 2.19.6 • DevTools 2.20.1
Version
7.5.1
Steps to Reproduce
flutter create sentry_flutter_web_stacktraces_repro
cd sentry_flutter_web_stacktraces_repro
flutter pub add sentry_flutter
flutter pub add dev:sentry_dart_plugin
Configure sentry_dart_plugin:
Replace
lib/main.dart
with the following:Configure DSN in
main.dart
flutter build web --source-maps
dart run sentry_dart_plugin
cd build/web
Start a web server to serve the files, e.g.
caddy file-server
Open the web app in a browser, wherever it is served, e.g.
http://localhost
.Click on the "Throw exception" button
Expected Result
The stack trace for error events sent to sentry should contain deobfuscated funtion names.
Actual Result
While the correct line and column numbers have been recovered, function names are not deobufscated:
Link to an example event: https://gabriel-59.sentry.io/issues/4170223115/events/234cd5801ab546e3a8812316462ebda4/?project=4505149812834304
Are you willing to submit a PR?
None