Skip to content

Commit 81faeb3

Browse files
committed
api test: Fix with_ to await callback first, then close
As is, the `finally` block gets run before the future returned by the callback has completed. I believe the underlying issue here is this one in the Dart SDK: dart-lang/sdk#44395 The fix is to await the future and return the result of that, rather than returning the future directly. The Dart language folks (or at least some of them) hope to eventually deal with this by making the old code here a type error, requiring the value passed to `return` to have type T rather than Future<T>: dart-lang/language#870
1 parent 519a6c5 commit 81faeb3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/api/fake_api.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class FakeApiConnection extends ApiConnection {
115115
? FakeApiConnection.fromAccount(account)
116116
: FakeApiConnection(realmUrl: realmUrl);
117117
try {
118-
return fn(connection);
118+
return await fn(connection);
119119
} finally {
120120
connection.close();
121121
}

0 commit comments

Comments
 (0)