Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
62cff9b
fix(okhttp): Don't block on response bodies of unknown length
carlonzo Oct 2, 2026
4d7c686
changelog: reference the pull request
carlonzo Oct 2, 2026
554d121
fix(okhttp): Satisfy detekt for the streaming body capture
carlonzo Oct 2, 2026
0d5e6df
refactor(okhttp): Drop unnecessary locking from the capturing source
carlonzo Oct 2, 2026
a982ceb
fix: Publish late response details safely
carlonzo Oct 2, 2026
1c6174f
test: Cover late-filled network request data
carlonzo Oct 2, 2026
9377594
fix(okhttp): Harden the capture of response bodies with no known length
markushi Oct 6, 2026
a93c694
test(okhttp): Cover async, cancelled and HTTP/2 bodies of unknown length
markushi Oct 6, 2026
b77f96a
ref: Publish both sides of NetworkRequestData the same way
markushi Oct 6, 2026
17d5134
fix(okhttp): Keep the bytes received before a stream breaks
markushi Oct 6, 2026
f9e79c0
ref: Read the response details of a network breadcrumb as one snapshot
markushi Oct 6, 2026
5b2bf58
ref(okhttp): Capture every response body through one path
markushi Oct 7, 2026
8879de2
changelog
markushi Oct 7, 2026
09687ef
test: Silence R8 for the okhttp types the new response body extends
markushi Oct 7, 2026
ead659c
ref(okhttp): Rename NetworkBodyCapturingResponseBody to CapturedRespo…
markushi Oct 8, 2026
8193c36
ref(okhttp): Capture only the response bytes the application reads
markushi Oct 8, 2026
406bd4e
Merge branch 'main' into fix/okhttp-unknown-length-response-body [pr-…
sentry-junior[bot] Oct 21, 2026
d490996
Merge branch 'main' into fix/okhttp-unknown-length-response-body [pr-…
sentry-junior[bot] Oct 22, 2026
6a5a086
test(okhttp): Wait for the capture, not for the source handing bytes …
markushi Oct 22, 2026
b406d8b
ref: Keep the status code inside the response details
markushi Oct 22, 2026
ab94b11
ref(okhttp): Restore the original response flow and rethrow fatal cap…
markushi Oct 22, 2026
7c50f57
ref(okhttp): Drop comments that restate the code
markushi Oct 22, 2026
fa85e61
ref: Drop the constructor comment on ReplayNetworkRequestOrResponse
markushi Oct 22, 2026
4dbcbfa
Merge branch 'main' into fix/okhttp-unknown-length-response-body [pr-…
sentry-junior[bot] Oct 22, 2026
c875cd0
Address PR comments
markushi Oct 23, 2026
2bc6c4f
Merge branch 'fix/okhttp-unknown-length-response-body' of github.com:…
markushi Oct 23, 2026
da019c0
Merge branch 'main' into fix/okhttp-unknown-length-response-body [pr-…
sentry-junior[bot] Oct 27, 2026
2599f05
address PR comments
markushi Nov 4, 2026
0e2906b
test(replay): Pin the response body a late capture leaves out of the …
markushi Nov 5, 2026
bbae16a
fix(okhttp): Capture network details only while Session Replay is rec…
markushi Nov 6, 2026
f3ecb6d
changelog
markushi Nov 6, 2026
ca5b9d7
Merge branch 'main' into fix/okhttp-gate-network-details-on-replay
markushi Nov 6, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
### Fixes

- Session Replay: Fix `SentryOkHttpInterceptor` hanging forever on responses whose body has no known length, such as Server-Sent Events or a gzipped response, when network details are enabled for the URL ([#6231](https://github.com/getsentry/sentry-java/pull/6231))
- Session Replay: `SentryOkHttpInterceptor` now captures network request and response details only while Session Replay is recording or buffering ([#6486](https://github.com/getsentry/sentry-java/pull/6486))
- Stop marking an OkHttp call span as failed when a connection attempt to one of the host's addresses fails but OkHttp connects on another ([#6472](https://github.com/getsentry/sentry-java/pull/6472))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,19 @@ public open class SentryOkHttpInterceptor(
var response: Response? = null
var code: Int? = null

// Network details only end up in a replay, so capturing them while no replay is recording or
// buffering is wasted work.
val networkDetailData =
NetworkDetailCaptureUtils.initializeForUrl(
request.url.toString(),
request.method,
scopes.options.sessionReplay.networkDetailAllowUrls,
scopes.options.sessionReplay.networkDetailDenyUrls,
)
if (scopes.options.replayController.isRecording) {
NetworkDetailCaptureUtils.initializeForUrl(
request.url.toString(),
request.method,
scopes.options.sessionReplay.networkDetailAllowUrls,
scopes.options.sessionReplay.networkDetailDenyUrls,
)
} else {
null
}

try {
val requestBuilder = request.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.check
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
Expand Down Expand Up @@ -90,10 +91,12 @@ class SentryOkHttpInterceptorTest {
sendDefaultPii: Boolean = false,
eventListener: EventListener? = null,
additionalInterceptors: List<Interceptor> = emptyList(),
isReplayRecording: Boolean = true,
optionsConfiguration: Sentry.OptionsConfiguration<SentryOptions>? = null,
): OkHttpClient {
options =
SentryOptions().also {
it.setReplayController(mock { on { isRecording } doReturn isReplayRecording })
optionsConfiguration?.configure(it)
it.dsn = "https://key@sentry.io/proj"
if (includeMockServerInTracePropagationTargets) {
Expand Down Expand Up @@ -381,6 +384,27 @@ class SentryOkHttpInterceptorTest {
assertNotNull(networkDetails.response)
}

@Test
fun `does not capture Session Replay network details when replay is not recording`() {
val sut =
fixture.getSut(
isReplayRecording = false,
optionsConfiguration = { it.sessionReplay.setNetworkDetailAllowUrls(listOf(".*")) },
)

sut.newCall(postRequest()).execute().close()

val hint = argumentCaptor<Hint>()
verify(fixture.scopes).addBreadcrumb(any(), hint.capture())
assertThat(
hint.firstValue.getAs(
TypeCheckHint.SENTRY_REPLAY_NETWORK_DETAILS,
NetworkRequestData::class.java,
)
)
.isNull()
}

@SuppressWarnings("SwallowedException")
@Test
fun `adds breadcrumb when http calls results in exception`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import okio.GzipSink
import okio.buffer
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
Expand All @@ -59,6 +60,7 @@ class SentryOkHttpInterceptorUnknownContentLengthTest {
options =
SentryOptions().apply {
dsn = "https://key@sentry.io/proj"
setReplayController(mock { on { isRecording } doReturn true })
sessionReplay.setNetworkDetailAllowUrls(listOf(".*"))
sessionReplay.setNetworkCaptureBodies(captureBodies)
}
Expand Down
Loading