Closed NeedleInAJayStack closed 1 year ago
🤔 I'm trying to work out why this was ever implemented like this. This looks like a good change though 👍
@gwynne any thoughts?
Because until I (finally) merged the custom functions support PR, this method - like most of the rest of SQLiteNIO - had been incorrectly implemented using NIOThreadPool.submit
, not NIOThreadPool.runIfActive
, which would call the work item body with an appropriate state (which the old implementation incorrectly ignored) in all cases. The promise leak is a new issue and a side effect of my incomplete review of the change I requested in the custom functions PR. Great catch, @NeedleInAJayStack! ❤️
Previously, trying to open a connection on an inactive thread pool would throw
Fatal error: leaking promise created at (file: "SQLiteNIO/SQLiteConnection.swift", line: 101)
. This was because the promise created on line 101 of SQLiteConnection.swift would not be succeeded or failed when therunIfActive
was called on an inactive thread pool. To resolve this, we avoid creating a newPromise
altogether, just using the one thatrunIfActive
provides.