Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An alternative way to provide correct stacktraces #1723

Closed
wants to merge 1 commit into from

Conversation

kuhnroyal
Copy link
Member

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

Additional context and info (if any)

@kuhnroyal kuhnroyal added s: feature This issue indicates a feature request p: dio Targeting `dio` package labels Mar 8, 2023
@kuhnroyal kuhnroyal self-assigned this Mar 8, 2023
await dio.get('/foo');
} catch (e, stackTrace) {
expect(stackTrace, isA<Chain>());
expect(stackTrace.toString(), contains('test/stacktrace_test.dart'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have there correct stacktrace here, something like this:

package:dio/src/dio_mixin.dart 556:7               DioMixin.fetch.<fn>
===== asynchronous gap ===========================
dart:async                                         Future.catchError
package:dio/src/dio_mixin.dart 549:8               DioMixin.fetch
package:dio/src/dio_mixin.dart 392:36              DioMixin.request.<fn>.<fn>
===== asynchronous gap ===========================
dart:async                                         new Future
package:dio/src/dio_mixin.dart 365:15              DioMixin.request.<fn>
package:stack_trace                                Chain.capture
package:dio/src/dio_mixin.dart 364:13              DioMixin.request
package:dio/src/dio_mixin.dart 63:12               DioMixin.get
test/stacktrace_test.dart 15:19                    main.<fn>.<fn>
package:test_api/src/backend/declarer.dart 215:19  Declarer.test.<fn>.<fn>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good, but I am not sure if tooling like Sentry/Crashlytics can work with this.

} catch (e, stackTrace) {
expect(stackTrace, isNot(isA<Chain>()));
expect(stackTrace.toString(),
isNot(contains('test/stacktrace_test.dart')));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have no usable stacktrace.

@kuhnroyal
Copy link
Member Author

Error.throwWithStackTrace does not exists in Dart 2.15, but is needed to make this work. bummer...

@ueman
Copy link
Contributor

ueman commented Mar 14, 2023

Error.throwWithStackTrace does not exists in Dart 2.15, but is needed to make this work. bummer...

If I had to guess, I would think most people are already using a higher Dart version

@kuhnroyal
Copy link
Member Author

I am closing this, this is very interesting with nice stacktraces and all but it is not the way to go inside a library.

@kuhnroyal kuhnroyal closed this Mar 14, 2023
@kuhnroyal kuhnroyal deleted the feature/async-problems branch March 16, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: dio Targeting `dio` package s: feature This issue indicates a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants