AudioStreaming icon indicating copy to clipboard operation
AudioStreaming copied to clipboard

Fatal error: couldn't found taskProvider

Open carlmachaalani opened this issue 6 months ago • 0 comments

Hi,

I regularly get this error when calling the stream function in the urlSession in NetworkSessionDelegate file. resetting the audio stream with a queue of new URLs. It does happen randomly, so I'm not quite sure where the source is from. The error gets thrown in the NetworkSessionDelegate file:

final class NetworkSessionDelegate: NSObject, URLSessionDataDelegate {
    weak var taskProvider: StreamTaskProvider?

    func stream(for task: URLSessionTask) -> NetworkDataStream? {
        guard let taskProvider = taskProvider else {
            assertionFailure("couldn't found taskProvider")
            return nil
        }
        return taskProvider.dataStream(for: task)
    }

    func urlSession(_: URLSession,
                    dataTask: URLSessionDataTask,
                    didReceive data: Data)
    {
        guard let stream = stream(for: dataTask) else {
            return
        }
        stream.didReceive(data: data,
                          response: dataTask.response as? HTTPURLResponse)
    }
    ....
}

Logs when the error happens:

>> engine stopped 🛑
Setting current reading entry to: (
    "[AudioEntry: AudioEntryId(unique: 42E8C754-B4F9-4665-A3FA-90C48F424E64, id: \"https://my-audio...")]"
)
engine started 🛵
AudioStreaming/NetworkSessionDelegate.swift:13: Fatal error: couldn't found taskProvider

I'll try to add in more context once I have more clues. Thanks!

carlmachaalani avatar Jul 31 '24 17:07 carlmachaalani