Skip to content

fix(native): implement HTTP client interface - #5987

Merged
ric-oliv merged 5 commits into
mainfrom
jpnurmi/ref/native-http
Nov 25, 2026
Merged

ric-oliv merged 5 commits into
mainfrom
jpnurmi/ref/native-http

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Description

The native SDK sent each envelope through a function transport that created a new HttpClient per envelope, blocked the capturing thread, and ignored the rate limits in the response.

Create the transport with sentry_http_transport_new instead, and send its requests with the HttpClient from the options. sentry-native now sends envelopes on its own transport thread and applies its rate limits, and the client can later serve the out-of-process crash daemon.

Issues

Refs #4867

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: high

For commit e26fe89.

Main concerns: reach, host performance, public contract.

This label is a hint for reviewers, not an approval.

@jpnurmi
jpnurmi marked this pull request as draft November 23, 2026 12:59
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 23, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2da29b8. Configure here.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing breaks the lines a PR changes on purpose, one mutation at a time, and checks that a test fails each time. A changed line no test runs fails the check, and a mutant that survives the tests only warns. Full report

Sentry: tests caught 3 of 4 mutants on the changed lines

Location Mutation Replaced with Status
src/Sentry/Internal/Http/GzipRequestBodyHandler.cs:93 Statement mutation ; Survived

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 9.45946% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.15%. Comparing base (1dbfd10) to head (e26fe89).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/Sentry/Platforms/Native/NativeHttpClient.cs 0.00% 66 Missing ⚠️
src/Sentry/Platforms/Native/CFunctions.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5987      +/-   ##
==========================================
+ Coverage   77.92%   78.15%   +0.23%     
==========================================
  Files         535      537       +2     
  Lines       19831    20077     +246     
  Branches     3967     4041      +74     
==========================================
+ Hits        15454    15692     +238     
- Misses       3533     3542       +9     
+ Partials      844      843       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 23, 2026
jpnurmi and others added 3 commits November 23, 2026 16:12
The native SDK sent each envelope through a function transport that
created a new `HttpClient` per envelope, blocked the capturing thread
and ignored the rate limits in the response.

Create the transport with `sentry_http_transport_new` instead, and
send its requests with the `HttpClient` from the options. sentry-native
now sends envelopes on its own transport thread and applies its rate
limits, and the client can later serve the out-of-process crash
daemon.

Ref: #4867

Co-authored-by: Claude Opus 5.5 <[email protected]>
Both handlers replace `request.Content` with a compressed wrapper, so
disposing the request left the original content undisposed. Content
backed by a file kept the file open until finalization.

Co-authored-by: Claude Opus 5.5 <[email protected]>
It only runs in Native AOT apps with sentry-native linked in, which no
unit test can load, so every mutant in it was reported as NoCoverage.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/native-http branch from 0d36554 to 0d46a4c Compare November 23, 2026 15:13
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 23, 2026
@jpnurmi
jpnurmi marked this pull request as ready for review November 23, 2026 15:17
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 23, 2026

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description says the client "can later serve the out-of-process crash daemon". How do you see that working?

From what I can see in 0.17.6, the daemon is the standalone sentry-crash executable (CMakeLists.txt), started as a separate process. It builds its own transport from what the parent puts in shared memory (DSN, proxy, CA certs). In a SENTRY_TRANSPORT=none build like ours, it gets the null transport (sentry_crash_daemon.c). An HttpClient in the app process can't reach that, and by the time the daemon uploads, the app has usually crashed.

Would we need to ship our own daemon executable that registers a client, or a new hook upstream? We also build with SENTRY_BACKEND=inproc today, so I assume this would come with a switch to the native backend. Not blocking this PR. I just want to know whether it should shape the design here.

A failed client start made `sentry_init` fail, so a throwing
`ConfigureClient` or `CreateHttpMessageHandler` disabled native crash
capture for the whole run. Now it only fails that request.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 24, 2026
@jpnurmi
jpnurmi added this pull request to stack #6000 November 24, 2026 07:58
@jpnurmi

jpnurmi commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Sorry for being stingy with the last part. I've made it visible as a draft:

The daemon gets its own copy of the client. sentry-native 1.0 adds SENTRY_TRANSPORT=custom, where the SDK supplies sentry_transport_new_default(). We build the sentry-crash daemon with one extra source that implements it by loading sentry-crash-transport, a small Native AOT library built from the same NativeHttpClient. The daemon then sends with its own HttpClient in its own process.

@jamescrosswell jamescrosswell changed the title ref(native): implement HTTP client interface fix(native): implement HTTP client interface Nov 24, 2026

@jamescrosswell jamescrosswell left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 25, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jpnurmi !

@ric-oliv
ric-oliv merged commit e7078a0 into main Nov 25, 2026
61 checks passed
@ric-oliv
ric-oliv deleted the jpnurmi/ref/native-http branch November 25, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants