Coder Social home page Coder Social logo

dart-lang / stack_trace Goto Github PK

View Code? Open in Web Editor NEW
128.0 128.0 20.0 440 KB

A package for manipulating stack traces and printing them readably.

Home Page: https://pub.dev/packages/stack_trace

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%

stack_trace's People

Contributors

amouravski avatar blois avatar chalin avatar cskau-g avatar dependabot[bot] avatar devoncarew avatar dgrove avatar floitschg avatar franklinyow avatar iposva-google avatar jacob314 avatar jakemac53 avatar jodinathan avatar keertip avatar kevmoo avatar kwalrath avatar lrhn avatar mraleph avatar munificent avatar natebosch avatar nex3 avatar pq avatar sethladd avatar sgjesse avatar sinegovsky-ivan avatar stereotype441 avatar vsmenon avatar whesse avatar winstonewert avatar yjbanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stack_trace's Issues

Remove unused Chain.disable functionality

I cannot find any uses of the Chain.disable API outside of the tests in this package. It is unnecessary complexity. Removing the functionality may also remove some of the overhead from this package since we can omit a boolean check and reading a zone variable for every zone callback.

Any concerns @jakemac53 @lrhn ?

get the original stack trace

Hi to all.
As I understand now it is impossible to get the original stack trace from a Trace or a Chain object.
But it can be very helpful to show stack traces in the dev-tool browser console in a way that the current browser understands and can transform them using sorce-maps files. I am going to use the "pretty-print" format to show stack-traces in the "dev-mode" and an original browser format in the production mode of my application.
I am going to add an originalTrace property to the Trace and to the Chain classes and save there a String that was used to create these objects.
Dear authors, what do you think about this improvement? Any requirements, advices or suggestions?

setExceptionPauseMode causes a breakpoint to be triggered with async exceptions that are caught

The VM Service Protocol provides the setExceptionPauseMode API. This API is used by debugging tools like the VSCode Dart Plugin or the IntelliJ Dart plugin when debugging, where the following RPC is sent over from the plugin:

==> {"id":"8","jsonrpc":"2.0","method":"setExceptionPauseMode","params":{"isolateId":"isolates/2741664618071259","mode":"Unhandled"}}

When this happens, uncaught exceptions at runtime will surface as breakpoints:

<== {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"PauseException","isolate": <truncated>

This has the same effect as the set break-on-exception Unhandled command in the debugger, and the --pause-isolates-on-unhandled-exceptions flag to dart.

Problem

With the following code, exceptions that are caught will surface in the debugger. Consider this:

import 'package:test/test.dart';

void main() {
  test('foo', () async {
    try {
      // Inlining [throwFooException] here also makes the problem go away.
      await throwFooException();
    } on FooException {
      print('caught fooexception');
    }
  });
}

class FooException implements Exception {}

Future<void> throwFooException() async {
  // Commenting this out makes the problem go away.
  // Wait for the next event.
  await Future(() {});
  throw FooException();
}

Running it through the package:test executable, or with dart directly will cause a breakpoint to be added where that exception is thrown, with an awkward backtrace coming from StackZoneSpecification.

With the Test Executable:

  1. pub run test --pause-after-load
  2. Go to the observatory debugger, and enter set break-on-exception Unhandled followed by continue
  3. Observe that a breakpoint has been added where we throw FooException()

Running it with pub run test --pause-after-load --no-chain-stack-traces and repeating the process does not cause the same issue though. The issue is with Chain.capture used to wrap user defined tests here in package:test_api.

With dart

  1. dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart
  2. Go to the observatory debugger, and enter continue
  3. Observe that a breakpoint has been added where we throw FooException()

Context

This particular pattern is used by, but is not limited to the package:integration_test binding under the hood. A MissingPluginException may be thrown and caught, but it will surface during IDE debugging which is confusing to users.

(cc @DanTup)

Smaller Repro

import 'package:stack_trace/stack_trace.dart';

class FooException implements Exception {}

Future<void> throwFooException() async {
  // Commenting it out makes the problem go away.
  // Wait for the next event.
  await Future(() {});
  throw FooException();
}

void main() {
  Chain.capture(() async {
    try {
      // Inlining [throwFooException] here also makes the problem go away.
      await throwFooException();
    } on FooException {
      print('caught fooexception');
    }
  });
}

Where the same command of dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart is able to reproduce it.

What seems to help is when this particular line is commented out. I couldn't quite follow what is going on with the recursion though, so I'm not sure what is the exact cause of this.

Versions

Dart SDK version: 2.13.0-38.0.dev (dev) (Mon Feb 15 10:21:50 2021 -0800) on "macos_x64"

stack_trace: 1.10.0

Should org-dartlang-sdk frames be stripped by `terse`?

Our code runs through Trace.terse, and we see (repeat) frames with the scheme 'org-dartlang-sdk' logged. I wasn't able to find much via google, and no issues here, but it seems like that would be a "core" frame that should be folded, doesn't it? (The current implementation is that only 'dart' scheme Uris in Frames are considered core.)

Here's an obfuscated example from our codebase:

org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/js_helper.dart 1342:37                                                     wrapException
https://cdn.foo.com/foo/packages/foo_sdk/src/public/client.dart 50:27                                                 createAuthenticatedFContext
https://cdn.foo.com/foo/packages/foo_sdk/src/public/client.dart 122:5                                                 FooClient.createFContext
https://cdn.foo.com/foo/packages/foo_sdk/src/public/client.dart 121:12                                                FooClient.createFContext[function-entry$0]
https://cdn.foo.com/foo/packages/foo_client/src/services/foo_service.dart 57:35                                       fooService._context
https://cdn.foo.com/foo/packages/foo_client/src/services/foo_service.dart 119:66                                      fooService.loadfooForAttachment
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 307:19                                                    _wrapJsFunctionForAsync
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 332:23                                                    _wrapJsFunctionForAsync.<anonymous function>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 237:3                                                     _asyncStartSync
https://cdn.foo.com/foo/packages/foo_client/src/services/foo_service.dart 111:59                                      fooService.loadfooForAttachment
https://cdn.foo.com/foo/packages/foo_client/src/services/foo_service.dart 111:59                                      fooService.loadfooForAttachment
https://cdn.foo.com/foo/packages/foo_client/src/experiences/foo/providers/foo_service_foo_provider.dart 117:40  fooServicefooProvider.fetchfoo
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 307:19                                                    _wrapJsFunctionForAsync
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 332:23                                                    _wrapJsFunctionForAsync.<anonymous function>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 237:3                                                     _asyncStartSync
https://cdn.foo.com/foo/packages/foo_client/src/experiences/foo/providers/foo_service_foo_provider.dart 114:56  fooServicefooProvider.fetchfoo
https://cdn.foo.com/foo/packages/foo_client/src/experiences/foo/providers/polling_foo_provider.dart 35:82          PollingfooProvider.startPolling.<anonymous function>
org-dartlang-sdk:///sdk/lib/async/zone.dart 1134:37                                                                             _rootRunUnary
org-dartlang-sdk:///sdk/lib/async/zone.dart 1132:3                                                                              _rootRunUnary[function-entry$5]
org-dartlang-sdk:///sdk/lib/async/zone.dart 1030:46                                                                             _CustomZone.runUnary
org-dartlang-sdk:///sdk/lib/async/zone.dart 1026:5                                                                              _CustomZone.runUnary[function-entry$2]
org-dartlang-sdk:///sdk/lib/async/zone.dart 933:7                                                                               _CustomZone.runUnaryGuarded
org-dartlang-sdk:///sdk/lib/async/zone.dart 931:8                                                                               _CustomZone.runUnaryGuarded[function-entry$2]
org-dartlang-sdk:///sdk/lib/async/zone.dart 970:26                                                                              _CustomZone.bindUnaryCallbackGuarded.<anonymous function>
org-dartlang-sdk:///sdk/lib/async/zone.dart 1138:12                                                                             _rootRunUnary
org-dartlang-sdk:///sdk/lib/async/zone.dart 1132:3                                                                              _rootRunUnary[function-entry$5]
org-dartlang-sdk:///sdk/lib/async/zone.dart 1030:46                                                                             _CustomZone.runUnary
org-dartlang-sdk:///sdk/lib/async/zone.dart 1026:5                                                                              _CustomZone.runUnary[function-entry$2]
org-dartlang-sdk:///sdk/lib/async/zone.dart 954:26                                                                              _CustomZone.bindUnaryCallback.<anonymous function>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 159:13                                                    _TimerImpl.periodic.<anonymous function>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/js_helper.dart 2015:14                                                     invokeClosure
https://app.foo.com/home/?next_url=https%3A%2F%2Fapp.foo.com%2Fhome%2F 16:23900                                             nrWrapper

If others want to fold those runs down to single frames, this code will do so:

  static String formatStackTrace(StackTrace stackTrace) =>
      Trace.from(stackTrace)
          .foldFrames(
            (Frame frame) => frame.uri.scheme.contains('org-dartlang-sdk'),
            terse: true,
          )
          .toString();

chain_test fails with Dart 2.0.0-dev.60.0

In dev.60, we landed a change to Stream and Zone onError callbacks: dart-lang/sdk@315a186#diff-3d86b3443b2ea32440e90f626168d61a

This causes chain_test to fail:

00:00 +6 -1: test/chain/chain_test.dart: Chain.capture() with no onError blocks errors [E]
  NoSuchMethodError: Closure call with mismatched arguments: function 'call'
  Receiver: Closure: (dynamic, dynamic) => dynamic
  Tried calling: call("OH NO")
  Found: call(dynamic, dynamic) => dynamic
  dart:async                        new Future.error
  test/chain/chain_test.dart 54:37  main.<fn>.<fn>.<fn>.<fn>
  package:stack_trace               Chain.capture
  test/chain/chain_test.dart 54:19  main.<fn>.<fn>.<fn>
  dart:async                        runZoned
  test/chain/chain_test.dart 52:7   main.<fn>.<fn>

An endless cycle on an error inside onError

Hello,

Can you help me to understand.
When an exception happens inside the onError callback of Chain.capture the onError callback will be called again, and again, and again. It generates an endless cycle.
Is it an expected behavior?
Code example:

import 'dart:async';
import 'package:stack_trace/stack_trace.dart';

void main() {
  return Chain.capture<Null>(
    () {
      throw new Exception('srcException');
    },
    when: true,
    onError: (dynamic error, Chain chain) {
      new Future.delayed(new Duration(seconds: 3)).then((_){
        print('throw internal ex');
        throw new Exception('internalEx');
      });

      print('onError!');
    }
  );
}

The result:

onError!
throw internal ex
onError!
throw internal ex
onError!
throw internal ex
onError!
...

Different behavior for log() compared to print()

I try to get my StackTraces logged.

It's working fine if I call:
print(Chain.current().terse);

StackTrace

flutter: package:stacktrace_test/main.dart 36:35                  HomePage.build.<fn>
package:flutter/src/material/ink_well.dart 1183:21       _InkResponseState.handleTap
package:flutter/src/gestures/recognizer.dart 275:24      GestureRecognizer.invokeCallback
package:flutter/src/gestures/tap.dart 652:11             TapGestureRecognizer.handleTapUp
package:flutter/src/gestures/tap.dart 309:5              BaseTapGestureRecognizer._checkUp
package:flutter/src/gestures/tap.dart 242:7              BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/src/gestures/recognizer.dart 630:9       PrimaryPointerGestureRecognizer.handleEvent
package:flutter/src/gestures/pointer_router.dart 98:12   PointerRouter._dispatch
package:flutter/src/gestures/pointer_router.dart 143:9   PointerRouter._dispatchEventToRoutes.<fn>
dart:collection                                          _LinkedHashMapMixin.forEach
package:flutter/src/gestures/pointer_router.dart 141:18  PointerRouter._dispatchEventToRoutes
package:flutter/src/gestures/pointer_router.dart 127:7   PointerRouter.route
package:flutter/src/gestures/binding.dart 488:19         GestureBinding.handleEvent
package:flutter/src/gestures/binding.dart 468:22         GestureBinding.dispatchEvent
package:flutter/src/rendering/binding.dart 439:11        RendererBinding.dispatchEvent
package:flutter/src/gestures/binding.dart 413:7          GestureBinding._handlePointerEventImmediately
package:flutter/src/gestures/binding.dart 376:5          GestureBinding.handlePointerEvent
package:flutter/src/gestures/binding.dart 323:7          GestureBinding._flushPointerEventQueue
package:flutter/src/gestures/binding.dart 292:9          GestureBinding._handlePointerDataPacket

If I try it with:
log('', stackTrace: Chain.current().terse)
The outputted StackTrace contains Chain( StackTrace )

StackTrace

[log] Chain (package:stacktrace_test/main.dart 43:35                  HomePage.build.<fn>
      package:flutter/src/material/ink_well.dart 1183:21       _InkResponseState.handleTap
      package:flutter/src/gestures/recognizer.dart 275:24      GestureRecognizer.invokeCallback
      package:flutter/src/gestures/tap.dart 652:11             TapGestureRecognizer.handleTapUp
      package:flutter/src/gestures/tap.dart 309:5              BaseTapGestureRecognizer._checkUp
      package:flutter/src/gestures/tap.dart 242:7              BaseTapGestureRecognizer.handlePrimaryPointer
      package:flutter/src/gestures/recognizer.dart 630:9       PrimaryPointerGestureRecognizer.handleEvent
      package:flutter/src/gestures/pointer_router.dart 98:12   PointerRouter._dispatch
      package:flutter/src/gestures/pointer_router.dart 143:9   PointerRouter._dispatchEventToRoutes.<fn>
      dart:collection                                          _LinkedHashMapMixin.forEach
      package:flutter/src/gestures/pointer_router.dart 141:18  PointerRouter._dispatchEventToRoutes
      package:flutter/src/gestures/pointer_router.dart 127:7   PointerRouter.route
      package:flutter/src/gestures/binding.dart 488:19         GestureBinding.handleEvent
      package:flutter/src/gestures/binding.dart 468:22         GestureBinding.dispatchEvent
      package:flutter/src/rendering/binding.dart 439:11        RendererBinding.dispatchEvent
      package:flutter/src/gestures/binding.dart 413:7          GestureBinding._handlePointerEventImmediately
      package:flutter/src/gestures/binding.dart 376:5          GestureBinding.handlePointerEvent
      package:flutter/src/gestures/binding.dart 323:7          GestureBinding._flushPointerEventQueue
      package:flutter/src/gestures/binding.dart 292:9          GestureBinding._handlePointerDataPacket
      )

Is there any way to get the stacktrace logged without the surrounding Chain()?

Code Example

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:stack_trace/stack_trace.dart';

void main() {
  runApp(
    const App(),
  );
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home Page'),
      ),
      body: Column(
        children: [
          ElevatedButton(
            onPressed: () {
              final chain = Chain.current();
              print(chain.terse);
            },
            child: const Text('Print Chain StackTrace'),
          ),
          ElevatedButton(
            onPressed: () {
              final chain = Chain.current();
              log('Test Message', stackTrace: chain.terse);
            },
            child: const Text('Log Chain StackTrace'),
          ),
          ElevatedButton(
            onPressed: () {
              final stackTrace = StackTrace.current;
              log('Test Message', stackTrace: stackTrace);
            },
            child: const Text('Log StackTrace'),
          ),
        ],
      ),
    );
  }
}

Add sample for Chain.terse

Thanks for your package - it is really helpful!!!! but it took me quite a while to figure out how to handle Chain.terse / Trace.terse...

Could you add a little sample to your README?

    void run() {
        Chain.capture( () {
            _loadAsyncProxy();

        },onError: (final error,final Chain chain) {

            _logger.shout(error,chain.terse);
        });
    }

How to print full stack trace ?

I made a minimum reproducible example to illustrate my issue :

Thanks to Gunthers's answer https://stackoverflow.com/questions/29013591/how-to-get-the-full-stack-trace-for-async-execution, I was able to print the full trace including every function called till the root of the test.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:stack_trace/stack_trace.dart';

late WidgetTester tester;
void expectFoo() {
  expect(find.text('Foos'), findsOneWidget);
}

Future<void> build() async {
  await tester.pumpWidget(Column(
    children: [
      CircularProgressIndicator(),
      Text('Foo', textDirection: TextDirection.ltr),
    ],
  ));
  await tester.pumpAndSettle(); // <- This fails the test
  expectFoo(); // <- This also fails the test but comment above line first
}

Future<void> setup() async {
  await build();
}

Future<void> testIfFooIsThere() async {
  await setup();
}

void main() {
  testWidgets('Stack trace', (WidgetTester _tester) async {
    tester = _tester;
    await Chain.capture(() async {
      await testIfFooIsThere();
    }, onError: (e, stack) {
      print(e);
      print("Chain ${Trace.from(stack).terse}");
      throw e;
    });
  });
}

With this code, it is meant to fail the test at pumpAndSettle(). Here is the trace:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _TextFinder:<zero widgets with text "Foos" (ignoring offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#1      fail (package:test_api/src/frontend/expect.dart:153:31)
#2      _expect (package:test_api/src/frontend/expect.dart:148:3)
#3      expect (package:test_api/src/frontend/expect.dart:57:3)
#4      expect (package:flutter_test/src/widget_tester.dart:441:3)
#5      expectFoo (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:7:3)
#6      build (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:18:3)
#9      main.<anonymous closure>.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:0:0)
#16     main.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:32:17)
#17     main.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:30:30)
#18     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)
(elided 8 frames from dart:async, dart:async-patch, and package:stack_trace)

The test description was:
  Stack trace

As you can see from the above trace, I get every function in the stack trace up to testWidgets > testIfFooIsThere > setup > build

But when I comment this line await tester.pumpAndSettle(); // <- This fails the test ,
I expect get an assertion error at expect(find.text('Foos'), findsOneWidget);

But the Stack trace only includes build and expectFoo

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _TextFinder:<zero widgets with text "Foos" (ignoring offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#1      fail (package:test_api/src/frontend/expect.dart:153:31)
#2      _expect (package:test_api/src/frontend/expect.dart:148:3)
#3      expect (package:test_api/src/frontend/expect.dart:57:3)
#4      expect (package:flutter_test/src/widget_tester.dart:441:3)
#5      expectFoo (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:7:3)
#6      build (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:18:3)
#9      main.<anonymous closure>.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:0:0)
#16     main.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:32:17)
#17     main.<anonymous closure> (file:///Users/samran/AndroidStudioProjects/flit_ride/test/widget_test.dart:30:30)
#18     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)
(elided 8 frames from dart:async, dart:async-patch, and package:stack_trace)

The test description was:
  Stack trace

Why ??

What should I do to make the second error trace behave like the first ?

Ultimately, my goal is to print every function with their line numbers from testWidgets up to the line that errored out, whenever an error occurred during the test. An alternative solution would be welcomed

How expensive is a `Trace.current()`

Hi,

I wonder if it costs a lot of performance to call Trace.current() on a regular basis or should this be avoided and only done when absolutely needed?

Cheers
Thomas

Is it expected that Chain.terse does not function in dart2js?

First off, this library is awesome. Using it in Dartium is extremely effective, however when I test in a javascript browser like Chrome it appears that the terse functionality is not taking effect. Is that expected? If so, it would be great to call that out in the README and possibly provide an explanation.

`Chain.capture()` fails to generate complete stack trace for `FileSystemException`

Steps to reproduce

Run the following code:

import 'dart:io';
import 'package:stack_trace/stack_trace.dart';

Future<void> badFunc() => File('foo').readAsString();

void main(List<String> arguments) async {
  await Chain.capture(() async {
    try {
      await badFunc();
    }
    catch (error, stackTrace) {
      print(stackTrace);
    }
  });
}

Output

#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:356:9)
#1      StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:36)
#2      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:204:15)
#3      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:24)
#4      _rootRunUnary (dart:async/zone.dart:1399:47)
#5      _CustomZone.runUnary (dart:async/zone.dart:1300:19)
<asynchronous suspension>
#6      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:15)
<asynchronous suspension>

Expected result

I am expecting to see some mention of main() and/or the source file name in the stack trace. However, as you can see, there is no mention of any user code in this stack trace at all.

Using stack_trace version 1.11.0.

Trace.parse() does not correctly parse standard stacks in stderr from the Dart VM

If I run:

main() {
  throw 'test';
}

I get the output:

Unhandled exception:
test
#0      main (file:///Users/danny/Desktop/dart_sample/bin/trace.dart:2:3)
#1      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

If I feed this into Trace.parse, it doesn't appear to parse correctly (it goes into Trace.parseFriendly, and that doesn't seem to handle this format):

import 'package:stack_trace/stack_trace.dart';

main() {
  final stderrOutput = '''
Unhandled exception:
test
#0      main (file:///Users/danny/Desktop/dart_sample/bin/trace.dart:2:3)
#1      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
'''
      .trim();

  final trace = Trace.parse(stderrOutput);
  for (final frame in trace.frames) {
    print('${frame.uri} ${frame.line}:${frame.column}');
  }
}

Outputs:

file:///Users/danny/Desktop/dart_sample null:null
file:///Users/danny/Desktop/dart_sample null:null
file:///Users/danny/Desktop/dart_sample null:null

The URIs and line/col don't seem to have been parsed correctly. Calling Trace.parseVm() works correctly, but I don't know for certain that the stack will always be from a VM and thought Trace.parse should handle this.

wasm stack frames are stripped out

When building a web application using Flutter and WebAssembly, we will often have stack frames in callstacks that don't have the typical javascript format of somefile.js:123:45, but instead have an hex address

ex:

at util::engine::SomeClass::SomeFunction() (https://some.url.com/some/path/some_app.wasm:wasm-function[66334]:0x12c28ad)

This makes it difficult to capture callstacks for crashes.

Pointers:
Frame.ParseV8 does not match a location generated by wasm:
https://github.com/dart-lang/stack_trace/blob/master/lib/src/frame.dart#L183

source_map_stack_trace filters out frames that are "Unparsed"
https://github.com/dart-lang/source_map_stack_trace/blob/master/lib/source_map_stack_trace.dart#L37

Frame.caller() is broken inside `Chain.capture`

The VM started giving us different, significantly truncated StackTrace instances when running in the zone for Chain.capture. Frame.caller() relies on parsing StackTrace.current which no longer contains the caller we were looking for.

Root Cause: dart-lang/sdk#46326

It's possible we could work around this with something like Chain.current() instead of StackTrace.current, but even with that we'd need to do specific detection that we're in the chain zone and handle the result differently.

Inside the Chain.capture the Chain.current() looks like

package:stack_trace/repro.dart 8:17           main.callee
===== asynchronous gap ===========================
dart:async/zone.dart 1286:19                  _CustomZone.registerUnaryCallback
dart:async-patch/async_patch.dart 45:22       _asyncThenWrapperHelper
package:stack_trace/repro.dart                main.callee
package:stack_trace/repro.dart 12:17          main.caller
package:stack_trace/repro.dart 11:22          main.caller
package:stack_trace/repro.dart 16:17          main.<fn>
package:stack_trace/repro.dart 15:23          main.<fn>
package:stack_trace/src/chain.dart 94:24      Chain.capture.<fn>
dart:async/zone.dart 1354:13                  _rootRun
dart:async/zone.dart 1258:19                  _CustomZone.run
dart:async/zone.dart 1789:10                  _runZoned
dart:async/zone.dart 1711:10                  runZoned
package:stack_trace/src/chain.dart 92:12      Chain.capture
package:stack_trace/repro.dart 15:15          main
dart:isolate-patch/isolate_patch.dart 283:19  _delayEntrypointInvocation.<fn>
dart:isolate-patch/isolate_patch.dart 184:12  _RawReceivePortImpl._handleMessage

While outside of it, it looks like

package:stack_trace/repro.dart 8:17  main.callee
===== asynchronous gap ===========================
package:stack_trace/repro.dart 12:5  main.caller
===== asynchronous gap ===========================
package:stack_trace/repro.dart 15:3  main

Trace.format is removing some information

When using Trace.format, some of the Stack Trace isn't being formatted right.

In the example below, "# 8" doesn't get formatted right, removing the line number and file name.

Stack :

#0      Crashlytics.crash (package:alyamin/utils/crashlytics/firebase_crashlytics.dart:53:5)
#1      HomePage.buildLayout.<anonymous closure> (package:alyamin/ui/home/HomePage.dart:81:44)
#2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#3      DoubleTapGestureRecognizer._checkUp (package:flutter/src/gestures/multitap.dart:307:7)
#4      DoubleTapGestureRecognizer._registerSecondTap (package:flutter/src/gestures/multitap.dart:280:5)
#5      DoubleTapGestureRecognizer._handleEvent (package:flutter/src/gestures/multitap.dart:208:9)
#6      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
#7      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
#8      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#9      PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
#10     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
#11     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
#12     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#13     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#14     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#15     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#16     _rootRunUnary (dart:async/zone.dart:1206:13)
#17     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#19     _invoke1 (dart:ui/hooks.dart:281:10)
#20     _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)

After Trace.format(stack) :

package:alyamin/utils/crashlytics/firebase_crashlytics.dart 53:5  Crashlytics.crash
package:alyamin/ui/home/HomePage.dart 81:44                       HomePage.buildLayout.<fn>
package:flutter/src/gestures/recognizer.dart 182:24               GestureRecognizer.invokeCallback
package:flutter/src/gestures/multitap.dart 307:7               DoubleTapGestureRecognizer._checkUp
package:flutter/src/gestures/multitap.dart 280:5                  DoubleTapGestureRecognizer._registerSecondTap
package:flutter/src/gestures/multitap.dart 208:9                  DoubleTapGestureRecognizer._handleEvent
package:flutter/src/gestures/pointer_router.dart 76:12            PointerRouter._dispatch
package:flutter/src/gestures/pointer_router.dart 122:9            PointerRouter._dispatchEventToRoutes.<fn>
dart:collection                                                   _LinkedHashMapMixin.forEach
package:flutter/src/gestures/pointer_router.dart 120:18           PointerRouter._dispatchEventToRoutes
package:flutter/src/gestures/pointer_router.dart 106:7            PointerRouter.route
package:flutter/src/gestures/binding.dart 218:19                  GestureBinding.handleEvent
package:flutter/src/gestures/binding.dart 198:22                  GestureBinding.dispatchEvent
package:flutter/src/gestures/binding.dart 156:7                   GestureBinding._handlePointerEvent
package:flutter/src/gestures/binding.dart 102:7                   GestureBinding._flushPointerEventQueue
package:flutter/src/gestures/binding.dart 86:7                    GestureBinding._handlePointerDataPacket
[✓] Flutter (Channel master, 1.19.0-2.0.pre.131, on Mac OS X 10.15.4 19E287, locale en-SY)
    • Flutter version 1.19.0-2.0.pre.131 at /Users/ucgmacmini/Library/flutter
    • Framework revision 478d4c9c1a (6 hours ago), 2020-05-19 20:22:01 -0700
    • Engine revision 2d4e83921d
    • Dart version 2.9.0 (build 2.9.0-9.0.dev 40f7a11d89)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/ucgmacmini/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.9.1

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] IntelliJ IDEA Community Edition (version 2020.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • 56BDDC91-4D51-4DCC-9F6D-0E92E3C77794 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

! Doctor found issues in 2 categories.

How to get only the caller class link ?

There is a someLoggerMethod(Trace.current().frames[1].member) , witch returns the caller function name. Is it a way to insert a caller class link too in console?
with result like

message, callerFunction , lib/className.dart //class link underlined

StackTrace with Chain.capture is not showing all line numbers

https://stackoverflow.com/questions/53641701/stacktrace-is-not-showing-line-numbers-for-every-point

I am using Chain.capture(() {...}); to execute async functions in Dart, but some points in StackTrace are not showing the line number, and those lines are the ones I need to debug :D
What can I do to see all line numbers?

Dart 2.1, VM

dart:async                                                      _completeOnAsyncReturn
package:oni_server/src/executor/executor.dart                   Executor.find
dart:async                                                      _completeOnAsyncReturn
package:oni_server/src/executor/executor.dart                   Executor.findMap
===== asynchronous gap ===========================
dart:async                                                      _AsyncAwaitCompleter.completeError
package:guaraci_tracker/visitor.dart                            Visitor.answered
===== asynchronous gap ===========================
dart:async                                                      _asyncThenWrapperHelper
package:guaraci_tracker/visitor.dart                            Visitor.answered
package:guaraci_tracker/visitor.dart 479:9                      Visitor.command
===== asynchronous gap ===========================
dart:async                                                      _asyncThenWrapperHelper
package:oni_server/src/socket/base_user.dart                    BaseSocketUser.process
bin/main.dart 18:18                                             main.<fn>.<fn>.<fn>
package:stack_trace                                             Chain.capture
bin/main.dart 17:13                                             main.<fn>.<fn>

Stack Trace is wrong in release mode (Flutter/Android)

Calling Trace.current() in debug works perfectly. However, calling Trace.current() in release mode yields a different stack which is definitely wrong (this code path is impossible). Most, if not all stack traces I get in release mode are like this (where one or two function calls are wrong).

Debug stack trace, showing correct GlobalChannelProxyService.createChannel call:

package:poly_scrabble_mobile/room_service/room_service.dart 52:36              RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 134:25             RoomService.callServer
package:poly_scrabble_mobile/services/global_channel_proxy_service.dart 17:33  GlobalChannelProxyService.createChannel
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 14:10   CreateChannelDialog.submit
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 44:17   CreateChannelDialog.build.<fn>
...

Release stack trace, showing impossible GameServiceProxy.executePlace call:

package:poly_scrabble_mobile/room_service/room_service.dart 52             RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 134            RoomService.callServer
package:poly_scrabble_mobile/services/game_proxy_service.dart 84           GameServiceProxy.executePlace
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 16  CreateChannelDialog.submit.<fn>

Please note GameServiceProxy.executePlace is never even called in the app. It is, however, an async function, which may be related. If I comment the GameServiceProxy.executePlace function, the release stack trace will be different, but still wrong:

Release stack trace with commented GameServiceProxy.executePlace function:

package:poly_scrabble_mobile/room_service/room_service.dart 52              RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 111             RoomService.reflectProp
package:poly_scrabble_mobile/services/self_user_proxy_service.dart 12       SelfUserProxyService.user
package:poly_scrabble_mobile/room_service/room_service.dart 165             RoomService._callServerBase
package:poly_scrabble_mobile/room_service/room_service.dart 148             RoomService.callServer
package:poly_scrabble_mobile/services/global_channel_proxy_service.dart 17  GlobalChannelProxyService.createChannel
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 14   CreateChannelDialog.submit
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 33   CreateChannelDialog.build.<fn>
...

Please note the SelfUserProxyService.user, which is also an impossible path. It looks like 2 stack traces got mangled in this case.

Package stack_trace prevents breakpoints from working

So I tried using the stack_trace package in my app, it works fine, except for this:

screenshot

If I remove the comments, the breakpoints don't work anymore. I'm using intelliJ ultimate with the Dart Plugin, with stack_trace version 1.3.2

Is this a known side-effect of using stack_trace or intended?

Problems with stacktraces with async functions

for a long time, I had a problem with my flutter_command package, when the Command had caught an exception the stacktrace was always truncated. I created a simplified version of my Commands in this demo repository:

https://github.com/escamoteur/stack_trace_demo

class CommandSimple {
  final Future<void> Function() asyncFunc;
  final String name;

  final isExecuting = ValueNotifier(false);

  CommandSimple(this.asyncFunc, this.name);

  void execute() async {
    isExecuting.value = true;

    /// give the async notifications a chance to propagate
    await Future<void>.delayed(Duration.zero);

    try {
      await _execute();
    } catch (e, s) {
      print('Error executing command $name: $s');
    } finally {
      isExecuting.value = false;

      /// give the async notifications a chance to propagate
      await Future<void>.delayed(Duration.zero);
    }
  }

  Future<void> _execute() async {
    await asyncFunc();
  }
}

the execute() is assigned to the tap handler of the FAB of the counter-example. and the wrapped function fails as intended but the stacktrace that I get looks like this

I/flutter (10938): Error executing command TestCommand: #0      IOClient.send
io_client.dart:119
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#1      BaseClient._sendUnstreamed
base_client.dart:93
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#2      _withClient
http.dart:166
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#3      level5
async_function_chain.dart:31
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#4      level4
async_function_chain.dart:24
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#5      level3
async_function_chain.dart:18
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#6      level2
async_function_chain.dart:12
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#7      level1
async_function_chain.dart:6
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#8      CommandSimple._execute
command.dart:30
I/flutter (10938): <asynchronous suspension>
I/flutter (10938): dart-lang/language#9      CommandSimple.execute
command.dart:18
I/flutter (10938): <asynchronous suspension>

It starts with the execute and any information from where this was called is lost. I tried if it makes a difference if I remove the Future.delayed but it didn't. additionally, I observed that for some wrapped functions especially if they contain .then or Future.toStream even this stack trace loses steps so that it's more difficult in 'post mortem debugging' to understand what exactly has happened.

I managed in the meantime to fix this problem using the stack_trace package but I'm not sure if what I do is ok or if it will lead to memory leaks.

The improved version you can find here:

https://github.com/escamoteur/stack_trace_demo/tree/optimized-stackstrace

with that, the stack trace looks like this:

I/flutter (11752): Error executing command TestCommand: package:http/src/io_client.dart 119:7                    IOClient.send
io_client.dart:119
I/flutter (11752): package:http/src/base_client.dart 93:32                  BaseClient._sendUnstreamed
base_client.dart:93
I/flutter (11752): package:http/http.dart 166:12                            _withClient
http.dart:166
I/flutter (11752): package:stack_trace_demo/async_function_chain.dart 31:7  level5
async_function_chain.dart:31
I/flutter (11752): package:stack_trace_demo/async_function_chain.dart 24:3  level4
async_function_chain.dart:24
I/flutter (11752): package:stack_trace_demo/async_function_chain.dart 18:3  level3
async_function_chain.dart:18
I/flutter (11752): package:stack_trace_demo/async_function_chain.dart 12:3  level2
async_function_chain.dart:12
I/flutter (11752): package:stack_trace_demo/async_function_chain.dart 6:3   level1
async_function_chain.dart:6
I/flutter (11752): package:stack_trace_demo/command.dart 22:7               CommandSimple.execute (TestCommand)
command.dart:22
I/flutter (11752): ===== asynchronous gap ===========================
I/flutter (11752): package:stack_trace_demo/command.dart 15:33              CommandSimple.execute
command.dart:15
I/flutter (11752): package:stack_trace_demo/main.dart 59:36                 _MyHomePageState.build.<fn>
main.dart:59
I/flutter (11752): package:flutter/src/material/ink_well.dart 1154:21       _InkResponseState.handleTap
ink_well.dart:1154
I/flutter (11752): package:flutter/src/gestures/recognizer.dart 275:

which is pretty slick.

The first problem that the stacktrace leading up to the call of the command was missing I added at the beginning of execute

    _traceBeforeExecute = Trace.current();

and join them together with the stacktrace I get in the catch and do some cleanup of frames that don't add to the understanding

  1. I would like if calling Trace.current() in a release version is ok or if it is very expensive?

  2. to solve the problem of missing frames when calling the wrapped function I added the following which works but feels pretty hacky

  Future<void> _execute() async {
    final completer = Completer<void>();
    Chain.capture(
      () => asyncFunc().then(completer.complete),
      onError: completer.completeError,
      when: true,
    );
    await completer.future;
  }

which helped perfectly in another example where a Future.Stream was involved, but in this simple example the stacktrace that I get at the catch is even shorter:

flutter: Error executing command TestCommand: package:http/src/io_client.dart 119:7                   IOClient.send
io_client.dart:119
level1
async_function_chain.dart:4
CommandSimple.execute (TestCommand)

Do I use the Chain.capture wrongly? and is it at all the right tool to get better async stacktraces or will the repeated creation of ErrorZones lead to memory leaks so that its better avoided completely? Also wen adding the capture VS code breaks at the first exception although it is handled.

If someone of the team could shed some light on this topic would be really appreciated.

Figure out handling of `errorZone` argument to `Chain.capture`

The doc comment has been misleading, likely since the when argument was introduced. There is some nuance to how the argument interacts with the presence of the onError argument that relates to the difference between ZoneSpecification. handleUncaughtError and ZoneSpecification. errorCallback (which I still can't keep straight).

Cannot use `catch` anymore when using `Chain.capture`

Very simple example:

void main() async {
  try {
    await g();
  } catch (e) {
    print('catch e=$e');
  }
}

Future<void> g() {
  throw Exception('fake error');
}

As expected, the output is catch e=Exception: fake error.

However, by wrapping g with Chain.capture as follows:

Future<void> g() {
  return Chain.capture(() async {
    throw Exception('fake error');
  });
}

Our catch no longer works! See below:

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: Exception: fake error
package:yplusplus/main.dart 60:5              g.<fn>
package:yplusplus/main.dart 59:24             g.<fn>
package:stack_trace/src/chain.dart 94:24      Chain.capture.<fn>
dart:async/zone.dart 1354:13                  _rootRun
dart:async/zone.dart 1258:19                  _CustomZone.run
dart:async/zone.dart 1789:10                  _runZoned
dart:async/zone.dart 1711:10                  runZoned
package:stack_trace/src/chain.dart 92:12      Chain.capture
package:yplusplus/main.dart 59:16             g
package:yplusplus/main.dart 52:11             main
dart:ui/hooks.dart 142:25                     _runMainZoned.<fn>.<fn>
dart:async/zone.dart 1354:13                  _rootRun
dart:async/zone.dart 1258:19                  _CustomZone.run
dart:async/zone.dart 1789:10                  _runZoned
dart:async/zone.dart 1777:12                  runZonedGuarded
dart:ui/hooks.dart 138:5                      _runMainZoned.<fn>
dart:isola<…>

This is very counter-intuitive. I wonder how can I solve this problem? In other words, I want to have the full stack trace (so I use capture), but at the same time, I want catch to work!

Thanks for any suggestions!

Chain.capture() not working in tests

Dear Dart-lang Maintainers,
Thank you for your hard work making Dart. It is very useful to me. Here is test/unit/truncated_trace_test.dart which demonstrates a problem in my Dart application:

import 'package:test/test.dart' show test;

class CustomException implements Exception {
  final String details;

  CustomException(dynamic e, StackTrace trace)
      : this.details = 'CustomException: $e\n'
            'Stack Trace:\n${Chain.forTrace(trace).terse}';

  @override
  String toString() => 'BEGIN\n$details\nEND\n';
}

Future<void> function2() async {
  try {
    throw new Exception('exception1');
  } catch (e, trace) {
    throw new CustomException(e, trace);
  }
}

Future<void> function1() async => await function2();

void main() {
  Chain.capture(() {
    test('test function1()', () async {
      await function1();
    });
  });
}

Here is the output of running the test:

00:01 +0 -1: test function1() [E]
  BEGIN
  CustomException: Exception: exception1
  Stack Trace:
  test/unit/truncated_trace_test.dart 17:5          function2
  ===== asynchronous gap ===========================
  dart:async                                        _asyncThenWrapperHelper
  package:test_api/src/backend/declarer.dart        Declarer.test.<fn>.<fn>.<fn>
  package:test_api/src/backend/invoker.dart 249:15  Invoker.waitForOutstandingCallbacks.<fn>
  ===== asynchronous gap ===========================
  dart:async                                        new Future
  package:test_api/src/backend/invoker.dart 398:11  Invoker._onRun.<fn>.<fn>.<fn>
  
  END
  
  test/unit/truncated_trace_test.dart 19:5  function2
  ===== asynchronous gap ===========================
  dart:async                                _AsyncAwaitCompleter.completeError
  test/unit/truncated_trace_test.dart       function2
  
00:01 +0 -1: Some tests failed.

The problem is that function1 and main are missing from the stack trace. So far this seems to happen only in tests. Is there any way to get the missing entries to show? I would appreciate any help you can give on this issue.

Sincerely,
Michael

More info:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ Brew can be used to install tools for iOS device development.
      Download brew at https://brew.sh/.
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Community Edition (version 2018.3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

Add Chain.terse examples to readme

Currently I am using
Future main() async { Chain.capture(() { myFunction() }; }
and I am not sure where I should add Chain.terse if I want to get rid of all the frames I don't care about.

One line example to the readme of how to use it inside the code may help other people understand it too.

Chain.capture could be generic

I saw some code that expected to get a Future<T> out of Chain.capture, where T is the type returned by the function.

I removed the generic for now, and just changed it to Future, but in some cases that might be undesirable

Type error?

I get this issue when compiling with dartdevc:

Error compiling dartdevc module:stack_trace|lib/lib__stack_trace.js

[error] The return type 'void' isn't a 'T', as defined by the method ''. (package:stack_trace/src/chain.dart, line 96, col 16)
[error] The argument type '(Zone, ZoneDelegate, Zone, Function) → () → dynamic' can't be assigned to the parameter type '<R>(Zone, ZoneDelegate, Zone, () → R) → () → R'. (package:stack_trace/src/stack_zone_specification.dart, line 69, col 9)
[error] The argument type '(Zone, ZoneDelegate, Zone, Function) → (dynamic) → dynamic' can't be assigned to the parameter type '<R,T>(Zone, ZoneDelegate, Zone, (T) → R) → (T) → R'. (package:stack_trace/src/stack_zone_specification.dart, line 70, col 9)
[error] The argument type '(Zone, ZoneDelegate, Zone, Function) → (dynamic, dynamic) → dynamic' can't be assigned to the parameter type '<R,T1,T2>(Zone, ZoneDelegate, Zone, (T1, T2) → R) → (T1, T2) → R'. (package:stack_trace/src/stack_zone_specification.dart, line 71, col 9)

Please fix all errors before compiling (warnings are okay).

[bug] one bug about Trace.terse

Hello dev:

print('Stack trace 1 :\n ${Trace.format(s, terse: true)}’); get a wrong format result when i cut off the network of my phone in below code? Thanks.

Or maybe is not the bug, just dart print function can not ouput the whole StackTrace, just print a part of StackTrace? So how to print the whole StackTrace?

static Stream<SearchState> _search(String term, GithubApi api) async* {
    if (term.isEmpty) {
      yield SearchNoTerm();
    } else {
      yield SearchLoading();

      try {
        final result = await api.search(term);

        if (result.isEmpty) {
          yield SearchEmpty();
        } else {
          yield SearchPopulated(result);
        }
      } catch (e, s) {
          print('Exception details:\n $e');
          print('Stack trace:\n $s');
          print('Stack trace 1 :\n ${Trace.format(s, terse: true)}');
          print('Stack trace 2 :\n ${Trace.format(s, terse: false)}');
        yield SearchError();
      }
    }
  }

Console output:

I/flutter (23099): Exception details:
I/flutter (23099):  SocketException: Failed host lookup: 'api.github.com' (OS Error: No address associated with hostname, errno = 7)
I/flutter (23099): Stack trace:
I/flutter (23099):  dart:async/future.dart 279:45                                 new Future.error
I/flutter (23099): dart:_http/http_impl.dart 2228:43                             _HttpClient._getConnection.connect
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 129:26  StackZoneSpecification._registerUnaryCallback.<fn>.<fn>
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 129:14  StackZoneSpecification._registerUnaryCallback.<fn>
I/flutter (23099): dart:async/zone.dart 1132:38                                  _rootRunUnary
I/flutter (23099): dart:async/zone.dart 1029:19                                  _CustomZone.runUnary
I/flutter (23099): dart:async/future_impl.dart 147:20                            _FutureListener.handleError
I/flutter (23099): dart:async/future_impl.dart 654:47                            Future._propagateToListeners.handleError
I/flutter (23099): dart:async/future_impl.dart 675:24                            Future._propagateToListeners
I/flutter (23099): dart:async/future_impl.dart 486:5                             Future.
I/flutter (23099): Stack trace 1 :
I/flutter (23099):  dart:_http                                                 _HttpClient.openUrl
I/flutter (23099): package:http/src/io_client.dart 33:36                      IOClient.send
I/flutter (23099): dart:async                                                 _AsyncStarStreamController.add
I/flutter (23099): package:startup_namer/github_search/search_bloc.dart 41:7  SearchBloc._search
I/flutter (23099): dart:async                                                 _StreamImpl.listen
I/flutter (23099): package:rxdart/src/transformers/switch_map.dart 47:55      SwitchMapStreamTransformer._buildTransformer.<fn>.<fn>.<fn>
I/flutter (23099): dart:async                                                 _StreamController.add
I/flutter (23099): package:rxdart/src/transformers/debounce.dart 44:34        DebounceStreamTransformer._buildTransformer.<fn>.<fn>.<fn>.<fn>
I/flutter (23099): dart:async                                                 _BoundSubscriptionStream.listen
I/flutter (23099): package:rxdart/src/observables/observable.dart 1729:20     Observable.listen
I/flutter (23099): package:rxdart/src/transformers/switch_map.dart 40:34      SwitchMapStreamTransformer._buildTransformer.<fn>.<fn>
I/flutter (23099): dar
I/flutter (23099): Stack trace 2 :
I/flutter (23099):  dart:async/future.dart 279:45                                 new Future.error
I/flutter (23099): dart:_http/http_impl.dart 2228:43                             _HttpClient._getConnection.connect
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 129:26  StackZoneSpecification._registerUnaryCallback.<fn>.<fn>
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
I/flutter (23099): package:stack_trace/src/stack_zone_specification.dart 129:14  StackZoneSpecification._registerUnaryCallback.<fn>
I/flutter (23099): dart:async/zone.dart 1132:38                                  _rootRunUnary
I/flutter (23099): dart:async/zone.dart 1029:19                                  _CustomZone.runUnary
I/flutter (23099): dart:async/future_impl.dart 147:20                            _FutureListener.handleError
I/flutter (23099): dart:async/future_impl.dart 654:47                            Future._propagateToListeners.handleError
I/flutter (23099): dart:async/future_impl.dart 675:24                            Future._propagateToListeners
I/flutter (23099): dart:async/future_impl.dart 486:5                             Futu

The demo is here

Allow line/column numbers to be separated with colon.

Currently, an example stack line looks like this:
src\main.dart 27:15 main
This looks really nice, however I would like an option for it to look like this:
src\main.dart:27:15 main
Note the line/column numbers are separated via : rather than a space.

The only reason I'd like it this way is because in certain terminals you can click (or CTRL+click) and it would open the file at that exact point. VSCode does this and is my primary driver, so it would make mine and possibly other people's lives easier if this was an option we could have when prettifying our stack traces.

1.6.3 Typo.

Failed to precompile test:test:
'package:stack_trace/src/chain.dart': error: line 38 pos 35: unterminated '{'
class Chain implements StackTrace {

StateError deep ind stack_trace code: Future already completed.

I currently get these here on a regular basis in Sentry:

StateError: Bad state: Future already completed
  File "future_impl.dart", line 18, in _Completer.completeError
  File "zone.dart", line 1666, in _RootZone.runBinary
  File "stack_zone_specification.dart", line 158, in StackZoneSpecification._handleUncaughtError
  File "zone.dart", line 1081, in _Zone._processUncaughtError
  File "zone.dart", line 1285, in _CustomZone.handleUncaughtError
  File "future_impl.dart", line 754, in Future._propagateToListeners
  File "future_impl.dart", line 649, in Future._completeError
  File "stack_zone_specification.dart", line 135, in StackZoneSpecification._registerBinaryCallback.<fn>.<fn>
  File "stack_zone_specification.dart", line 204, in StackZoneSpecification._run
  File "stack_zone_specification.dart", line 135, in StackZoneSpecification._registerBinaryCallback.<fn>
  File "zone.dart", line 1423, in _rootRunBinary
  File "zone.dart", line 1315, in _CustomZone.runBinary
  File "future_impl.dart", line 171, in _FutureListener.handleError
  File "future_impl.dart", line 852, in Future._propagateToListeners.handleError
  File "future_impl.dart", line 873, in Future._propagateToListeners
  File "future_impl.dart", line 649, in Future._completeError
  File "stack_zone_specification.dart", line 135, in StackZoneSpecification._registerBinaryCallback.<fn>.<fn>
  File "stack_zone_specification.dart", line 204, in StackZoneSpecification._run
  File "stack_zone_specification.dart", line 135, in StackZoneSpecification._registerBinaryCallback.<fn>
  File "zone.dart", line 1423, in _rootRunBinary
  File "zone.dart", line 1315, in _CustomZone.runBinary
  File "future_impl.dart", line 171, in _FutureListener.handleError
  File "future_impl.dart", line 852, in Future._propagateToListeners.handleError
  File "future_impl.dart", line 873, in Future._propagateToListeners
  File "future_impl.dart", line 649, in Future._completeError
  File "future_impl.dart", line 550, in Future._chainForeignFuture.<fn>
  File "stack_zone_specification.dart", line 204, in StackZoneSpecification._run
  File "stack_zone_specification.dart", line 114, in StackZoneSpecification._registerCallback.<fn>
  File "zone.dart", line 1399, in _rootRun
  File "zone.dart", line 1301, in _CustomZone.run
  File "zone.dart", line 1209, in _CustomZone.runGuarded
  File "zone.dart", line 1249, in _CustomZone.bindCallbackGuarded.<fn>
  File "schedule_microtask.dart", line 40, in _microtaskLoop
  File "schedule_microtask.dart", line 49, in _startMicrotaskLoop

This is how I use Chain.capture to get better stacktraces when en exception happens in the wrapped async function of a flutter_command:

        final completer = Completer<TResult>();
        Chain.capture(
          () => _func!(param as TParam).then(completer.complete),
          onError: completer.completeError,
        );
        result = await completer.future;

The use of the completer this way was the only way I could get back a meaningful stack_trace from Chain.capture

Chain.capture loses information if there are synchronous throws in async methods

Original issue, filed on the test repo dart-lang/test#1038.

Minimal repro:

import 'package:stack_trace/stack_trace.dart';

main() async {
  await Chain.capture(foo, onError: (e, chain) {
    print('$e\n${chain.terse}');
  });
}

Future<void> foo() async {
  throw 'foo';
}

Output:

foo
test/foo.dart 10:3  foo
===== asynchronous gap ===========================
dart:async          _AsyncAwaitCompleter.completeError
test/foo.dart       foo

You can add an await null at the top of the foo method to get the expected output:

foo
test/foo.dart 11:3   foo
===== asynchronous gap ===========================
dart:async           _AsyncAwaitCompleter.completeError
test/foo.dart        foo
===== asynchronous gap ===========================
dart:async           _asyncThenWrapperHelper
test/foo.dart        foo
package:stack_trace  Chain.capture
test/foo.dart 4:15   main

Note that if you use the native stack traces from the vm you do get the full stack trace as well.

cc @vsmenon for prioritization/assignment

Chain.foldFrames crashes on empty list

I'm not sure exactly when it gets into this situation but it can be called with an empty list. You can see an example [here]:

stderr:
Unhandled exception:
Bad state: No element
#0      Object&ListMixin.single (dart:collection/list.dart:85)
#1      Chain.foldFrames.<anonymous closure> (package:stack_trace/src/chain.dart:163:27)
#2      WhereIterator.moveNext (dart:_internal/iterable.dart:436)
#3      Iterable.isEmpty (dart:core/iterable.dart:375)
#4      Chain.foldFrames (package:stack_trace/src/chain.dart:168:24)
#5      terseChain (package:test/src/utils.dart:152:41)
#6      ExpandedReporter._onError (package:test/src/runner/reporter/expanded.dart:218:19)
#7      ExpandedReporter._onTestStarted.<anonymous closure> (package:test/src/runner/reporter/expanded.dart:187:9)
#8      _rootRunUnary (dart:async/zone.dart:918)
#9      _RootZone.runUnaryGuarded (dart:async/zone.dart:1089)
...

1.24.0-dev.4.2

When an pkg/http connection fails I get this stack – with pubviz

Not sure if this is an SDK issue or stack_trace.

I'm on SDK

HandshakeException: Connection terminated during handshake
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      new Timer (dart:async/timer.dart:52)
unparsed       #6      Timer.run (dart:async/timer.dart:90)
unparsed       #7      new Future (dart:async/future.dart:156)
unparsed       #8      _HttpClient._getConnection (dart:io/http_impl.dart:1910)
unparsed       #9      _HttpClient._openUrl (dart:io/http_impl.dart:1813)
unparsed       #10     _HttpClient.openUrl (dart:io/http_impl.dart:1718)
unparsed       #11     IOClient.send (package:http/src/io_client.dart:43)
<asynchronous  suspension>
unparsed       #12     BaseClient._sendUnstreamed (package:http/src/base_client.dart:171)
<asynchronous  suspension>
unparsed       #13     BaseClient.get (package:http/src/base_client.dart:34)
unparsed       #14     get.<anonymous closure> (package:http/http.dart:47)
unparsed       #15     _withClient (package:http/http.dart:167)
<asynchronous  suspension>
unparsed       #16     get (package:http/http.dart:47)
unparsed       #17     getLatestVersion (package:pubviz/src/util.dart:9)
<asynchronous  suspension>
unparsed       #18     VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:86)
<asynchronous  suspension>
unparsed       #19     VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #20     _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #21     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #22     Future.wait (dart:async/future.dart:355)
unparsed       #23     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #24     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #25     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #26     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #27     _rootRun (dart:async/zone.dart:1120)
unparsed       #28     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #29     runZoned (dart:async/zone.dart:1467)
unparsed       #30     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #31     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #32     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #33     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      IOClient.send (package:http/src/io_client.dart:39)
unparsed       #8      BaseClient._sendUnstreamed (package:http/src/base_client.dart:171)
<asynchronous  suspension>
unparsed       #9      BaseClient.get (package:http/src/base_client.dart:34)
unparsed       #10     get.<anonymous closure> (package:http/http.dart:47)
unparsed       #11     _withClient (package:http/http.dart:167)
<asynchronous  suspension>
unparsed       #12     get (package:http/http.dart:47)
unparsed       #13     getLatestVersion (package:pubviz/src/util.dart:9)
<asynchronous  suspension>
unparsed       #14     VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:86)
<asynchronous  suspension>
unparsed       #15     VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #16     _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #17     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #18     Future.wait (dart:async/future.dart:355)
unparsed       #19     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #20     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #21     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #22     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #23     _rootRun (dart:async/zone.dart:1120)
unparsed       #24     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #25     runZoned (dart:async/zone.dart:1467)
unparsed       #26     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #27     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #28     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      BaseClient._sendUnstreamed (package:http/src/base_client.dart:152)
unparsed       #8      BaseClient.get (package:http/src/base_client.dart:34)
unparsed       #9      get.<anonymous closure> (package:http/http.dart:47)
unparsed       #10     _withClient (package:http/http.dart:167)
<asynchronous  suspension>
unparsed       #11     get (package:http/http.dart:47)
unparsed       #12     getLatestVersion (package:pubviz/src/util.dart:9)
<asynchronous  suspension>
unparsed       #13     VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:86)
<asynchronous  suspension>
unparsed       #14     VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #15     _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #16     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #17     Future.wait (dart:async/future.dart:355)
unparsed       #18     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #19     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #20     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #21     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #22     _rootRun (dart:async/zone.dart:1120)
unparsed       #23     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #24     runZoned (dart:async/zone.dart:1467)
unparsed       #25     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #26     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #27     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #28     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      _withClient (package:http/http.dart:164)
unparsed       #8      get (package:http/http.dart:47)
unparsed       #9      getLatestVersion (package:pubviz/src/util.dart:9)
<asynchronous  suspension>
unparsed       #10     VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:86)
<asynchronous  suspension>
unparsed       #11     VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #12     _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #13     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #14     Future.wait (dart:async/future.dart:355)
unparsed       #15     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #16     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #17     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #18     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #19     _rootRun (dart:async/zone.dart:1120)
unparsed       #20     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #21     runZoned (dart:async/zone.dart:1467)
unparsed       #22     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #23     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #24     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #25     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      getLatestVersion (package:pubviz/src/util.dart:7)
unparsed       #8      VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:86)
<asynchronous  suspension>
unparsed       #9      VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #10     _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #11     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #12     Future.wait (dart:async/future.dart:355)
unparsed       #13     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #14     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #15     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #16     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #17     _rootRun (dart:async/zone.dart:1120)
unparsed       #18     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #19     runZoned (dart:async/zone.dart:1467)
unparsed       #20     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #21     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #22     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      VizPackage.updateLatestVersion (package:pubviz/src/viz_package.dart:83)
unparsed       #8      VizPackage.forDirectory (package:pubviz/src/viz_package.dart:58)
<asynchronous  suspension>
unparsed       #9      _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #10     MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #11     Future.wait (dart:async/future.dart:355)
unparsed       #12     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #13     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #14     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #15     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #16     _rootRun (dart:async/zone.dart:1120)
unparsed       #17     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #18     runZoned (dart:async/zone.dart:1467)
unparsed       #19     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #20     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #21     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerUnaryCallback (dart:async/zone.dart:1045)
unparsed       #4      _asyncThenWrapperHelper (dart:async-patch/async_patch.dart:30)
unparsed       #5      VizPackage.forDirectory (package:pubviz/src/viz_package.dart:38)
unparsed       #6      _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:119)
<asynchronous  suspension>
unparsed       #7      MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #8      Future.wait (dart:async/future.dart:355)
unparsed       #9      _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #10     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #11     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #12     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #13     _rootRun (dart:async/zone.dart:1120)
unparsed       #14     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #15     runZoned (dart:async/zone.dart:1467)
unparsed       #16     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #17     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #18     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #19     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      _getReferencedPackages.<anonymous closure> (package:pubviz/src/viz_root.dart:117)
unparsed       #8      MappedIterator.moveNext (dart:_internal/iterable.dart:391)
unparsed       #9      Future.wait (dart:async/future.dart:355)
unparsed       #10     _getReferencedPackages (package:pubviz/src/viz_root.dart:127)
<asynchronous  suspension>
unparsed       #11     VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #12     main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #13     Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #14     _rootRun (dart:async/zone.dart:1120)
unparsed       #15     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #16     runZoned (dart:async/zone.dart:1467)
unparsed       #17     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #18     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #19     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerUnaryCallback (dart:async/zone.dart:1045)
unparsed       #4      _asyncThenWrapperHelper (dart:async-patch/async_patch.dart:30)
unparsed       #5      _getReferencedPackages (package:pubviz/src/viz_root.dart:112)
unparsed       #6      VizRoot.forDirectory (package:pubviz/src/viz_root.dart:25)
<asynchronous  suspension>
unparsed       #7      main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #8      Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #9      _rootRun (dart:async/zone.dart:1120)
unparsed       #10     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #11     runZoned (dart:async/zone.dart:1467)
unparsed       #12     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #13     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #14     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerUnaryCallback (dart:async/zone.dart:1045)
unparsed       #4      _asyncThenWrapperHelper (dart:async-patch/async_patch.dart:30)
unparsed       #5      VizRoot.forDirectory (package:pubviz/src/viz_root.dart:23)
unparsed       #6      main.<anonymous closure> (http://localhost:57487/pubviz.dart:40)
<asynchronous  suspension>
unparsed       #7      Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #8      _rootRun (dart:async/zone.dart:1120)
unparsed       #9      _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #10     runZoned (dart:async/zone.dart:1467)
unparsed       #11     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #12     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #13     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
===== asynchronous gap ===========================
unparsed       #3      _CustomZone.registerCallback (dart:async/zone.dart:1034)
unparsed       #4      _CustomZone.bindCallback (dart:async/zone.dart:924)
unparsed       #5      scheduleMicrotask (dart:async/schedule_microtask.dart:148)
unparsed       #6      new Future.microtask (dart:async/future.dart:182)
unparsed       #7      main.<anonymous closure> (http://localhost:57487/pubviz.dart:39)
unparsed       #8      Chain.capture.<anonymous closure> (package:stack_trace/src/chain.dart:92)
unparsed       #9      _rootRun (dart:async/zone.dart:1120)
unparsed       #10     _CustomZone.run (dart:async/zone.dart:1001)
unparsed       #11     runZoned (dart:async/zone.dart:1467)
unparsed       #12     Chain.capture (package:stack_trace/src/chain.dart:90)
unparsed       #13     main (http://localhost:57487/pubviz.dart:39)
<asynchronous  suspension>
unparsed       #14     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
unparsed       #15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)

Format exception with 1.9 SDK + async

FormatException: Couldn't parse VM stack trace line '#5      main.<anonymous closure>.<<anonymous closure>_async_body> (file:///Users/kevmoo/source/github/source_gen.dart/test/project_generator_test.dart)'.

Dart VM version: 1.9.0-dev.7.1

CC @nex3

Dart 2 runtime failures in tests

Running vm_test.dart in dart 2 mode

00:01 +26 -1: forTrace() within capture() called for an unregistered stack trace uses the current chain [E]
Expected: an object with length of <2>
Actual: [
Trace:stack_trace/test/chain/vm_test.dart 463:11 main...
Trace:stack_trace/src/chain.dart 101:24 Chain.capture.
dart:async/zone.dart 1126:13 _rootRun
dart:async/zone.dart 1023:19 _CustomZone.run
dart:async/zone.dart 1501:17 runZoned

Which: has length of <7>

package:test expect
../../stack_trace/test/chain/vm_test.dart 470:7 main..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.