             self.sendMutex.synchronize {
               // if there are messages pending, send the next one
               if self.messageQueue.count > 0 {
-                let nextMessage = self.messageQueue.removeFirst()
+                let (nextMessage, nextErrorHandler) = self.messageQueue.removeFirst()
                 do {
-                  try self.sendWithoutBlocking(data: nextMessage, errorHandler: errorHandler)
+                  try self.sendWithoutBlocking(data: nextMessage, errorHandler: nextErrorHandler)
                 } catch (let callError) {
                   errorHandler(callError)
                 }

  private var owned: Bool

  /// A queue of pending messages to send over the call
  private var messageQueue: Array<Data>

  /// True if a message write operation is underway
  private var writing: Bool

    self.underlyingCall = underlyingCall
    self.owned = owned
    self.completionQueue = completionQueue
    writing = false
    sendMutex = Mutex()
  }
