Skip to content

Commit 56811db

Browse files
authored
Handle new style VM data URI frames (flutter#73)
See dart-lang/test#1261 Somewhere between Dart `2.1.0` and Dart `2.2.0` the output from the VM for stack frames in `data:` URIs changed. The new format wraps with `<>` and does not include the full URI. Check specifically whether the matched "uri" is instead a truncated and bracketed `data:` URI and treat it as if it were a valid empty data URI.
1 parent 4d1ef4e commit 56811db

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.9.5
2+
3+
* Parse the format for `data:` URIs that the Dart VM has used since `2.2.0`.
4+
15
## 1.9.4
26

37
* Add support for firefox anonymous stack traces.

lib/src/frame.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ class Frame {
149149
var member = match[1]
150150
.replaceAll(_asyncBody, '<async>')
151151
.replaceAll('<anonymous closure>', '<fn>');
152-
var uri = Uri.parse(match[2]);
152+
var uri = match[2].startsWith('<data:')
153+
? Uri.dataFromString('')
154+
: Uri.parse(match[2]);
153155

154156
var lineAndColumn = match[3].split(':');
155157
var line =

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: stack_trace
2-
version: 1.9.4
2+
version: 1.9.5
33

44
description: A package for manipulating stack traces and printing them readably.
55
homepage: https://github.com/dart-lang/stack_trace

test/frame_test.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,17 @@ baz@https://pub.dev/buz.js:56355:55
568568
equals(path.join('foo', 'bar.dart')));
569569
});
570570

571-
test('truncates data: URIs', () {
571+
test('truncates legacy data: URIs', () {
572572
var frame = Frame.parseVM(
573573
'#0 Foo (data:application/dart;charset=utf-8,blah:0:0)');
574574
expect(frame.library, equals('data:...'));
575575
});
576+
577+
test('truncates data: URIs', () {
578+
var frame = Frame.parseVM(
579+
'#0 main (<data:application/dart;charset=utf-8>:1:15)');
580+
expect(frame.library, equals('data:...'));
581+
});
576582
});
577583

578584
group('.location', () {

0 commit comments

Comments
 (0)