Open sadeghgoo opened 3 years ago
```swift public func write(_ data: Data, withTimeout timeout: TimeInterval, tag: Int) { internalQueue.async { let newWrite = WriteItem(tag: tag, timeout: (timeout > 0.0) ? .now() + timeout : .distantFuture) self.scheduledWrites.insert(newWrite) self.checkScheduledWrites() self.connection?.write(data: data) { possibleError in if let error = possibleError { self.closeConnection(withError: error) } else { guard self.scheduledWrites.remove(newWrite) != nil else { return } guard let delegate = self.delegate else { return } delegate.socket(self, didWriteDataWithTag: tag) } } } }
Crash occurred on guard self.scheduledWrites.remove(newWrite) != nil else { return }
Console log:
CocoaMQTT was compiled with optimization - stepping may behave oddly; variables may not be available.
I'm also encountering both crashes you posted @sadeghgoo related to this function and the scheduledWrites property. Looks like this property is overloaded with items and it leads to a memory issue. Did anyone find a fix?
Crash occurred on
guard self.scheduledWrites.remove(newWrite) != nil else { return }