dart-lang / stack_trace

A package for manipulating stack traces and printing them readably.
https://pub.dev/packages/stack_trace
BSD 3-Clause "New" or "Revised" License
129 stars 22 forks source link

[bug] one bug about Trace.terse #49

Closed Guang1234567 closed 2 months ago

Guang1234567 commented 5 years ago

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

osa1 commented 2 months ago

This looks like a bug somewhere else, it looks like the string output was cut off during printing (or writing to a socket/fd etc.).

get a wrong format result when i cut off the network of my phone in below code

How do you expect the program to send the logs without a network connection?