Skip to content

Conversation

@weihanyau
Copy link

@weihanyau weihanyau commented Jan 7, 2026

Summary:

Fix Issue #55081

Changelog:

[ANDROID] [FIXED] - Fix Android XMLHttpRequest timeout error by catching InterruptedIOException in addition to SocketTimeoutException

Test Plan:

Copied over the code from the reproducer into the RNTesterPlayground.js from issue #55081 and confirmed that the ontimeout error is working properly now

Before After
react-native-timeout-current.webm
react-native-timeout-fixed.webm

@meta-cla
Copy link

meta-cla bot commented Jan 7, 2026

Hi @weihanyau!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla
Copy link

meta-cla bot commented Jan 7, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 7, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 7, 2026
@weihanyau weihanyau changed the title fix(android): fix XMLHttpRequest ontimeout fix(android): fix XMLHttpRequest timeout error trigger onerror instead of ontimeout Jan 7, 2026
@javache
Copy link
Member

javache commented Jan 7, 2026

Let's catch both? SocketTimeoutException may still happen if we fail to establish the TCP socket in time, while the InterruptedIOException seems to coming from a different level in the response handling stack.

@weihanyau
Copy link
Author

weihanyau commented Jan 7, 2026

Let's catch both? SocketTimeoutException may still happen if we fail to establish the TCP socket in time, while the InterruptedIOException seems to coming from a different level in the response handling stack.

Oops, you are correct. Updated to catch for both.

Tested by adding another button in the playground that will call http://10.255.255.1 to mock TCP timeout.
After testing again seems like this is throwing InterruptedIOException too, do you have a way to test the case where it will throw SocketTimeoutException?

Edit: From what I observed from the okhttp repo, it seems like the only error that will be thrown is InterruptedIOException. Should we still catch both just in case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants