Repository navigation
APISecurity: onNewAPIToken / onLogout return FutureOr<void>, awaited (v1.37.0) - #214
Merged
Merged
Conversation
… errors logged (v1.37.0) A hook doing async work (storing the refresh token) ran detached: it outlived the request, and its error was an unhandled async error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #214 +/- ##
==========================================
+ Coverage 95.95% 95.97% +0.02%
==========================================
Files 75 75
Lines 26035 26042 +7
==========================================
+ Hits 24982 24994 +12
+ Misses 1053 1048 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…2.25) Replaces the private _callHook: same behavior (sync stays sync, errors logged, never propagated). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
APISecurity:
onNewAPIToken/onLogoutreturnFutureOr<void>and are awaited (v1.37.0)Why. Both hooks were
void, called without being awaited. A subclass storing something in them, as an app persisting the refresh token, got detached work:In AllDely's CI, the last test of a file issued a token, then
tearDownAllclosed the database while the hook's store still ran. The result wasBad state: Closed DBAdapterand a test that "failed after test completion", on some runs only.How the hooks are called. They go through
async_extension's newtryCallWithValue(1.2.25, now on pub.dev), which keeps theFutureOrbehavior:Futureor microtask is added, so a synchronous chain stays synchronous.Futureis chained: the authentication, refresh or logout completes after it.severeand never fails the operation, which already happened.Compatibility.
voidandFutureOr<void>are mutual subtypes, so existingvoidoverrides still compile.void ... asyncreturns aFutureat runtime and is now awaited. That is the behavior change, hence the minor version.Tests (
bones_api_cov_security_test.dart)A
_HookSecuritywith sync / async / throws / asyncError hooks covers:authenticate,refreshAPITokenand logout complete;authenticateandrefreshAPITokensynchronous;Without the change, 3 of these fail; the asyncError one fails "after it had already completed".
dart analyzeis clean anddart pub publish --dry-runhas 0 warnings.🤖 Generated with Claude Code