Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ public class ReconnectingWebSocket(
}
}

private fun reconnect() {
private fun reconnect(detail: String? = null, cause: Throwable? = null) {
check(!closed) { "Can't reconnect closed client" }

if (!suppressConnectionErrors) {
FLog.w(TAG, "Couldn't connect to \"$url\", will silently retry")
val suffix = if (detail == null) "" else " ($detail)"
val message = "Couldn't connect to \"$url\"$suffix, will silently retry"
if (cause == null) {
FLog.w(TAG, message)
} else {
FLog.w(TAG, message, cause)
}
suppressConnectionErrors = true
}

Expand Down Expand Up @@ -107,7 +113,10 @@ public class ReconnectingWebSocket(
}
if (!closed) {
connectionCallback?.onDisconnected()
reconnect()
// `t` distinguishes a rejected upgrade from never reaching the server: okhttp
// reports the former as `Expected HTTP 101 response but was '<code> <message>'`,
// so `response` carries nothing extra worth reading off it here.
reconnect(cause = t)
}
}

Expand All @@ -126,7 +135,7 @@ public class ReconnectingWebSocket(
this.webSocket = null
if (!closed) {
connectionCallback?.onDisconnected()
reconnect()
reconnect("closed by peer with code $code: \"$reason\"")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,7 @@ public class ReactHostImpl(
{ task ->
val isMetroRunning = checkNotNull(task.getResult())
if (isMetroRunning) {
// Since metro is running, fetcxception(method, "ReactContext is null. Reload
// reason: $h the JS bundle from the server
// Since metro is running, fetch the JS bundle from the server
loadJSBundleFromMetro()
} else {
Task.forResult(reactHostDelegate.jsBundleLoader)
Expand All @@ -1157,7 +1156,16 @@ public class ReactHostImpl(
bgExecutor,
)
} else {
if (ReactBuildConfig.DEBUG) {
if (useDevSupport) {
// Dev support is on, so the developer expects to be editing JS against a packager, but
// the bundle can only come from the app. Nothing downstream reports this, because no
// packager request is ever made.
FLog.w(
TAG,
"Dev support is enabled but packager server access is not. The JS bundle will be " +
"loaded from the app and the development server will not be used.",
)
} else if (ReactBuildConfig.DEBUG) {
FLog.d(TAG, "Packager server access is disabled in this environment")
}

Expand Down
Loading