Skip to content

Commit

Permalink
Disable connection read timeout for Network.loadNetworkResource (Andr…
Browse files Browse the repository at this point in the history
…oid) (facebook#46041)

Summary:
Pull Request resolved: facebook#46041

We observed that large or remotely loaded source maps could time out. This change aligns `OkHttpClient` timeout values with `CxxInspectorPackagerConnection`.

https://github.com/facebook/react-native/blob/a77f26827fee0fc18a11faccd0b5e51d1b222735/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/CxxInspectorPackagerConnection.java#L87-L91

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D61333240

fbshipit-source-id: 605b1fbf1b050d8e80ed569b25cb5694e2d14ec7
  • Loading branch information
huntie authored and facebook-github-bot committed Aug 15, 2024
1 parent 49fa92e commit 2469c67
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
Expand All @@ -25,7 +26,12 @@ private InspectorNetworkHelper() {}

public static void loadNetworkResource(String url, InspectorNetworkRequestListener listener) {
if (client == null) {
client = new OkHttpClient();
client =
new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read
.build();
}

Request request;
Expand Down

0 comments on commit 2469c67

Please sign in to comment.