Skip to content

fix: Silenced network error in CRTClientEngine onStreamComplete callback #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

sichanyoo
Copy link
Contributor

@sichanyoo sichanyoo commented May 27, 2025

Issue #

Description of changes

Adds back continuation.resume(throwing:) to onStreamComplete callback in CRTClientEngine. The continuation resumption was removed in this previous PR: #922. At the time of removal, the logic was that by the time onStreamComplete callback is reached, the continuation must have been resumed in the onResponse callback since onResponse callback gets called as soon as we get headers from the service. But on transient network errors, only the onStreamComplete could get called & onResponse could be skipped. This causes continuation to never get resumed, silencing error & essentially "freezing" a thread.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -571,6 +571,7 @@ public class CRTClientEngine: HTTPClient {
case .failure(let error):
self.logger.error("Response encountered an error: \(error)")
stream.closeWithError(error)
continuation.resume(throwing: error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're sure we don't need this in the success branch of the switch as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, the success with status code means valid response was returned from the service, meaning onResponse would've been called already that resumes the continuation. Not to mention customer's been using v1.2.9 of aws-sdk-swift that depends on v.0.112.0 of smithy-swift without any issues, which only has this resume logic in failure case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I guess we can re-evaluate if we see this problem reoccur.

@sichanyoo sichanyoo requested a review from jbelkins May 27, 2025 18:00
@sichanyoo sichanyoo merged commit e310145 into main May 27, 2025
33 checks passed
@sichanyoo sichanyoo deleted the fix/crt-client-engine-silenced-network-error branch May 27, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants