update:Improve Timeout Detection in Network Requests #43548
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve Timeout Detection in Network Requests
Summary:
This PR aims to enhance the detection mechanism for request timeouts in the network layer of React Native. The existing implementation only considers SocketTimeoutException for marking a request as timed out. However, this approach misses scenarios where timeouts might occur due to other reasons that manifest as InterruptedIOException with a specific message indicating a timeout. The proposed changes ensure that the application accurately flags such timeout occurrences, providing a more reliable and comprehensive handling of timeout conditions.
Changelog:
[Android] [Changed] [NetworkModule] - Expand timeout detection to include InterruptedIOException alongside SocketTimeoutException, improving reliability in identifying request timeouts.
Test Plan:
Before Changes: The timeout detection was limited to SocketTimeoutException, which did not cover all possible timeout scenarios. As a result, certain timeout conditions could pass unnoticed, leading to inconsistent behavior in network error handling.
After Changes: The detection has been expanded to include instances of InterruptedIOException with a message indicating a timeout, alongside the original SocketTimeoutException. This broader approach allows for a more accurate identification of timeout-related errors.
Testing was performed by simulating both SocketTimeoutException and InterruptedIOException with a "timeout" message. The updated logic successfully flagged both instances as timeouts, demonstrating the effectiveness of the proposed enhancement.