Skip to content

Commit e757c56

Browse files
committed
Fix nil import error?
1 parent 9a6e89c commit e757c56

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Firestore/Source/Public/FirebaseFirestore/FIRFirestore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ NS_SWIFT_NAME(Firestore)
143143
* block will run even if the client is offline, unless the process is killed.
144144
*/
145145
- (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **))updateBlock
146-
completion:(void (^)(id _Nullable result, NSError *_Nullable error))completion;
146+
completion:(void (^)(id _Nullable result, NSError *_Nullable error))completion
147+
__attribute__((swift_async_error(nonnull_error)));
147148

148149
/**
149150
* Creates a write batch, used for performing multiple writes as a single

Firestore/Swift/Tests/Integration/AsyncAwaitIntegrationTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ let emptyBundle = """
4343
XCTAssertTrue(snapshot.exists)
4444
}
4545

46+
func testRunTransactionDoesNotCrashOnNilSuccess() async throws {
47+
let document = collectionRef().document()
48+
let value = try await db.runTransaction({ transact, error in
49+
transact.setData(["test": "test"], forDocument: document)
50+
return nil // should not crash
51+
})
52+
53+
XCTAssertNil(value, "value should be nil on success")
54+
}
55+
4656
func testLoadBundleFromData() async throws {
4757
let bundle = "\(emptyBundle.count)\(emptyBundle)"
4858
let bundleProgress = try await db.loadBundle(Data(bundle.utf8))

0 commit comments

Comments
 (0)