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

Fix: Context Escape with ScopeCallback #925

Merged
merged 21 commits into from
Jul 6, 2022
Merged

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Jul 4, 2022

📜 Description

ScopeCallback

  • Change ScopeCallback from void Function(Scope) to FutureOr<void> Function(Scope)

configureScope

  • Change static void configureScope(ScopeCallback callback) to static FutureOr<void> configureScope(ScopeCallback callback) in Sentry class.
  • Change void configureScope(ScopeCallback callback) to FutureOr<void> configureScope(ScopeCallback callback) in Hub class.

clone

  • Change static Hub clone() to static Future<Hub> clone() in Sentry class.
  • Change static Hub clone() to static Future<Hub> clone() in Hub/HubAdapter classes.
  • Change Scope clone() to Future<Scope> clone() in Scope class.

addBreadcrumb

  • Change static void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) to static Future<void> addBreadcrumb(Breadcrumb crumb, {dynamic hint}) in Scope class.
  • Change void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) to Future<void> addBreadcrumb(Breadcrumb crumb, {dynamic hint}) in Hub/HubAdapter class.

Other

  • Remove internal async methods in SentryNavigatorObserver, as they were only ever called from sync methods.

💡 Motivation and Context

Closes #921

💚 How did you test it?

Ran tests.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

dart/lib/src/hub.dart Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2022

Codecov Report

Merging #925 (b5759d7) into main (a5e904f) will increase coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #925      +/-   ##
==========================================
+ Coverage   89.77%   89.94%   +0.16%     
==========================================
  Files         104        9      -95     
  Lines        3208      169    -3039     
==========================================
- Hits         2880      152    -2728     
+ Misses        328       17     -311     
Impacted Files Coverage Δ
dio/lib/src/breadcrumb_client_adapter.dart 80.00% <100.00%> (ø)
logging/lib/src/logging_integration.dart 90.47% <100.00%> (ø)
dart/lib/src/http_client/breadcrumb_client.dart
dart/lib/src/hub.dart
dart/lib/src/hub_adapter.dart
dart/lib/src/noop_hub.dart
dart/lib/src/scope.dart
dart/lib/src/sentry.dart
dart/lib/src/sentry_tracer.dart
...lib/src/invalid_sentry_trace_header_exception.dart
... and 87 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5e904f...b5759d7. Read the comment docs.

@denrase denrase marked this pull request as ready for review July 4, 2022 14:36
@denrase denrase requested a review from brustolin as a code owner July 4, 2022 14:36
@marandaneto
Copy link
Contributor

@denrase PR is marked ready to review but there are open issues still.
E.g. #925 (comment)

dart/lib/src/hub.dart Outdated Show resolved Hide resolved
dart/lib/src/scope.dart Outdated Show resolved Hide resolved
@marandaneto
Copy link
Contributor

marandaneto commented Jul 5, 2022

Hub#addBreadcrumb should also return a Future<void> since it calls Scope#addBreadcrumb
Worth enabling unawaited_futures: true lint rule and double-check that, maybe there are more methods that we've forgotten to change it.

dart/test/hub_test.dart Outdated Show resolved Hide resolved
@denrase
Copy link
Collaborator Author

denrase commented Jul 5, 2022

CI issue occurs from running pana. Can't seem to call FutureOr<void> configureScope(ScopeCallback callback) in SentryNavigatorObserver with await. Works if calling without await, which we technically don't need, as our closures are not async, but this might affect others when calling the new API? I haven't seen this error before, all tests run as expected. Maybe @ueman has an idea why this is reported as an error?

Bildschirmfoto 2022-07-05 um 17 14 26

@marandaneto
Copy link
Contributor

I believe it could be because of how pana runs again.
The public API changed but pana checks the latest published version instead the local version.
dart-lang/pana#1020
In this case, we can ignore it as long as pana runs locally just fine.

@marandaneto marandaneto merged commit c8ffeec into main Jul 6, 2022
@marandaneto marandaneto deleted the fix/sope-callback-signature branch July 6, 2022 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context escape with ScopeCallback
3 participants