Skip to content

Commit

Permalink
Handle new style VM data URI frames
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
natebosch committed Jun 30, 2020
1 parent 4d1ef4e commit 2ccccd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.9.5

* Parse the format for `data:` URIs that the Dart VM has used since `2.2.0`.

## 1.9.4

* Add support for firefox anonymous stack traces.
Expand Down
4 changes: 3 additions & 1 deletion lib/src/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class Frame {
var member = match[1]
.replaceAll(_asyncBody, '<async>')
.replaceAll('<anonymous closure>', '<fn>');
var uri = Uri.parse(match[2]);
var uri = match[2].startsWith('<data:')
? Uri.dataFromString('')
: Uri.parse(match[2]);

var lineAndColumn = match[3].split(':');
var line =
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: stack_trace
version: 1.9.4
version: 1.9.5

description: A package for manipulating stack traces and printing them readably.
homepage: https://github.com/dart-lang/stack_trace
Expand Down
8 changes: 7 additions & 1 deletion test/frame_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,17 @@ baz@https://pub.dev/buz.js:56355:55
equals(path.join('foo', 'bar.dart')));
});

test('truncates data: URIs', () {
test('truncates legacy data: URIs', () {
var frame = Frame.parseVM(
'#0 Foo (data:application/dart;charset=utf-8,blah:0:0)');
expect(frame.library, equals('data:...'));
});

test('truncates data: URIs', () {
var frame = Frame.parseVM(
'#0 main (<data:application/dart;charset=utf-8>:1:15)');
expect(frame.library, equals('data:...'));
});
});

group('.location', () {
Expand Down

0 comments on commit 2ccccd4

Please sign in to comment.