Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumenting HTTPX somehow breaks CORS in pyodide #825

Open
samuelcolvin opened this issue Jan 29, 2025 · 1 comment
Open

Instrumenting HTTPX somehow breaks CORS in pyodide #825

samuelcolvin opened this issue Jan 29, 2025 · 1 comment

Comments

@samuelcolvin
Copy link
Member

samuelcolvin commented Jan 29, 2025

Description

See https://pydantic.run/store/2394806888132a13

Code is

# /// script
# dependencies = ['logfire[httpx]', 'httpx']
# ///
import logfire
import httpx

logfire.configure(send_to_logfire=False)
logfire.instrument_httpx(capture_all=True)

r = httpx.get('https://global-power-plants.datasettes.com/global-power-plants.db')
r.raise_for_status()
print('datasize:', len(r.content))

If I comment out logfire.instrument_httpx(capture_all=True) it works fine.

Python, Logfire & OS Versions, related packages (not required)

logfire="3.4.0"
platform="Emscripten-3.1.58-wasm32-32bit"
python="3.12.7 (main, Jan 23 2025, 22:14:53) [Clang 19.0.0git (https:/github.com/llvm/llvm-project 0a8cd1ed1f4f35905df318015b"
[related_packages]
requests="2.31.0"
protobuf="5.29.2"
rich="13.7.1"
executing="2.0.1"
opentelemetry-api="1.29.0"
opentelemetry-exporter-otlp-proto-common="1.29.0"
opentelemetry-exporter-otlp-proto-http="1.29.0"
opentelemetry-instrumentation="0.50b0"
opentelemetry-instrumentation-httpx="0.50b0"
opentelemetry-proto="1.29.0"
opentelemetry-sdk="1.29.0"
opentelemetry-semantic-conventions="0.50b0"
opentelemetry-util-http="0.50b0"
@alexmojaki
Copy link
Contributor

Access to XMLHttpRequest at 'https://global-power-plants.datasettes.com/global-power-plants.db' from origin 'https://pydantic.run' has been blocked by CORS policy: Request header field traceparent is not allowed by Access-Control-Allow-Headers in preflight response.

So we need to prevent context propagation in HTTP clients under pyodide.

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

No branches or pull requests

2 participants