Skip to content

T-17170 Resolve proxy settings once so forked RQ work horses on macOS stop crashing at flush - #49

Merged
PetrHeinz merged 2 commits into
masterfrom
claude/t-17170-proxy-settings-once
Sep 25, 2026
Merged

PetrHeinz merged 2 commits into
masterfrom
claude/t-17170-proxy-settings-once

Conversation

@PetrHeinz

Copy link
Copy Markdown
Member

Testing 0.4.1 end to end on macOS: every RQ work horse run by logtail.rq.Worker crashed during its flush, and the job's records were lost while RQ still reported the job as finished, because the flush runs after the status is written. The crash is inside requests' proxy lookup: with no proxy environment variables set, requests asks macOS SystemConfiguration for proxy settings on every request, and CoreFoundation refuses to run in a child forked from a multithreaded process. An RQ worker is always multithreaded at fork time (it runs a pubsub listener thread), so nothing about this is specific to the handler's flush thread, and OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES does not help, since that silences the Objective-C check but not the CoreFoundation one. Linux has no such lookup and is unaffected.

The first commit adds the tests and is expected to fail CI. The second commit makes the uploader resolve the proxy settings and the CA bundle from the environment once, when it is created, and pins them on the session with trust_env=False. The fork reset then gives the child a fresh session with the same resolved settings instead of a new uploader, so the child never consults SystemConfiguration. What changes for everyone:

  • proxies (HTTPS_PROXY, NO_PROXY, macOS or Windows system settings) and REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE are read once per handler instead of on every upload, resolved with the same requests helper the per-request path uses
  • a .netrc entry for the ingesting host is no longer applied; it would have replaced the bearer token with basic auth
  • one SystemConfiguration round trip less per upload on macOS

Verified on a Mac with the RQ scenario that crashed on 0.4.1: three runs with this change, zero crash reports, every job record delivered, no duplicated worker lines. CI cannot reproduce the crash, the tests pin the resolved settings and their survival across the fork reset.

🤖 Generated with Claude Code

PetrHeinz and others added 2 commits September 25, 2026 14:57
…ng them across the fork reset

requests asks the environment, and on macOS SystemConfiguration, for proxy settings on every request. A forked RQ work horse crashes in that lookup, so the uploader must resolve the settings once in the parent and its fresh post-fork session must reuse them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s fresh session

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz marked this pull request as ready for review September 25, 2026 13:00
@PetrHeinz
PetrHeinz merged commit c1ee9c7 into master Sep 25, 2026
13 checks passed
@PetrHeinz
PetrHeinz deleted the claude/t-17170-proxy-settings-once branch September 25, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant