fix(rest): make HttpClient safe for concurrent requests - #19
Open
smaheshwar-pltr wants to merge 1 commit into
Open
smaheshwar-pltr wants to merge 1 commit into
smaheshwar-pltr wants to merge 1 commit into
Conversation
smaheshwar-pltr
force-pushed
the
fix/rest-http-client-thread-safety
branch
from
September 25, 2026 10:11
7ec1933 to
74b5a2d
Compare
This was referenced Sep 25, 2026
smaheshwar-pltr
force-pushed
the
fix/rest-http-client-thread-safety
branch
from
September 25, 2026 21:05
74b5a2d to
79e980e
Compare
smaheshwar-pltr
force-pushed
the
fix/rest-http-client-thread-safety
branch
from
September 25, 2026 21:44
79e980e to
14c719e
Compare
HttpClient sent every request through one cpr::ConnectionPool, and libcurl does not support sharing a connection cache between threads. Overlapping requests, for example from token refresh or the metrics executor, could crash. Give each in-flight request its own pool and reuse idle pools. HttpResponse now copies the status, body and headers out of cpr::Response, whose curl handle must be freed before its pool is reused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
smaheshwar-pltr
force-pushed
the
fix/rest-http-client-thread-safety
branch
from
September 25, 2026 23:14
14c719e to
dee5b68
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20.
Each request now takes a
cpr::ConnectionPoolthat no other request is using and returns it afterwards, so connections are still reused.HttpResponsenow copies the status, body and headers out ofcpr::Response, whose curl handle must be freed before its pool is reused. This also stops libcurl from evicting connections when more than five requests are in flight (its defaultCURLOPT_MAXCONNECTS).The new test crashes without the fix on some libcurl versions, such as 8.22.0, but not on 8.18.0, which CI uses.
🤖 Generated with Claude Code