-
Notifications
You must be signed in to change notification settings - Fork 6
[Internal] Improve Lock Error handling #69
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves lock error handling in the Swift PowerSync SDK by removing the need for custom TransactionCallback
and LockCallback
wrapper classes. The changes address Swift/Objective-C compatibility issues and compiler warnings related to optionality mismatches.
- Removes custom callback wrapper classes that had Swift 6 compatibility issues
- Replaces callback wrappers with new Kotlin SDK wrapper functions
- Introduces standardized error handling using
PowerSyncResult
enum
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
Sources/PowerSync/Kotlin/TransactionCallback.swift | Completely removes the file containing custom callback wrapper classes |
Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift | Updates method calls to use new wrapper functions and adds helper functions for error handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I also like that this lets us remove Swift-specific logic from the :core
Kotlin project.
Overview
It's currently tricky to throw Errors from Swift closure functions which are provided to the Kotlin SDK.
We currently achieve exception propagation for the
readLock
,readTransaction
,writeLock
andwriteTransaction
methods by implementingTransactionCallback
andLockCallback
wrappers on the Swift side. These wrappers:SKIEE has known limitations with generics. Which causes some rather strange requirements for the
TransactionCallback
andLockCallback
implementations.The
execute
method of these implementations should be able to returnAny?
(a nullable response). But this is not possible due to Objective C limitations:This causes us to define the
execute
method as returningAny
which works, but prints a warning on every compile.Furthermore. When enabling the Swift 6 toolchain while making Swift 6 declaration changes. The compiler seems to crash when processing the
TransactionCallback.swift
file.This PR removes the need for
TransactionCallback
andLockCallback
in the Swift SDK, by making use of the changes in Kotlin PR