Skip to content

Commit 43baf46

Browse files
authored
Fix bug where error sent by server via stream is silenced. It happens bc as soon as headers are returned the continuation gets resumed, and resuming continuation again in the case of stream error does nothing and error doesn't get bubbled up. This change sends error back up by closing stream with it. (#922)
1 parent 755367a commit 43baf46

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,11 @@ public class CRTClientEngine: HTTPClient {
536536
switch result {
537537
case .success(let statusCode):
538538
response.statusCode = makeStatusCode(statusCode)
539+
stream.close()
539540
case .failure(let error):
540541
self.logger.error("Response encountered an error: \(error)")
541-
continuation.safeResume(error: error)
542+
stream.closeWithError(error)
542543
}
543-
544-
// closing the stream is required to signal to the caller that the response is complete
545-
// and no more data will be received in this stream
546-
stream.close()
547544
}
548545

549546
requestOptions.http2ManualDataWrites = http2ManualDataWrites

0 commit comments

Comments
 (0)