Skip to content

Commit 07d6c9f

Browse files
hack fix watch exceptions
1 parent 55d93f8 commit 07d6c9f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol {
183183
Task {
184184
do {
185185
var mapperError: Error?
186+
// HACK!
187+
// SKIEE doesn't support custom exceptions in Flows
188+
// Exceptions which occur in the Flow itself cause runtime crashes.
189+
// The most probable crash would be the internal EXPLAIN statement.
190+
// This attempts to EXPLAIN the query before passing it to Kotlin
191+
// We could introduce an onChange API in Kotlin which we use to implement watches here.
192+
// This would prevent most issues with exceptions.
193+
_ = try await self.kotlinDatabase.get(sql: "EXPLAIN \(options.sql)", parameters: options.parameters, mapper: {_ in ""})
186194
for try await values in try self.kotlinDatabase.watch(
187195
sql: options.sql,
188196
parameters: options.parameters,

0 commit comments

Comments
 (0)