Skip to content

fix(android): fix XMLHttpRequest timeout error trigger onerror instead of ontimeout#55080

Open
weihanyau wants to merge 2 commits into
react:mainfrom
weihanyau:fix_android_xhr_timeout_error
Open

fix(android): fix XMLHttpRequest timeout error trigger onerror instead of ontimeout#55080
weihanyau wants to merge 2 commits into
react:mainfrom
weihanyau:fix_android_xhr_timeout_error

Conversation

@weihanyau

@weihanyau weihanyau commented Jan 7, 2026

Copy link
Copy Markdown

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

meta-cla Bot commented Jan 7, 2026

Copy link
Copy Markdown

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 cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jan 7, 2026

Copy link
Copy Markdown

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

javache commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

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

weihanyau commented Jan 7, 2026

Copy link
Copy Markdown
Author

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?

@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 7, 2026
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. Stale There has been a lack of activity on this issue and it may be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants