When looking through the code I noticed that the Task created in startWriterTask doesn't catch or consume errors and nothing awaits the Task completion. The upshot is that any errors thrown here are ignored which is likely to be problematic.
|
let task = Task { |
|
dispatchPrecondition(condition: .notOnQueue(Self.streamQueue)) |
|
for try await chunk in httpBody { |
|
try await withCheckedThrowingContinuation { continuation in |
|
Self.streamQueue.async { |
|
debug("Output stream delegate produced chunk and suspended producer.") |
|
self.performAction(self.state.producedChunkAndSuspendedProducer(chunk, continuation)) |
|
} |
|
} |
|
} |
|
Self.streamQueue.async { |
|
debug("Output stream delegate wrote final chunk.") |
|
self.performAction(self.state.wroteFinalChunk()) |
|
} |
|
} |