denoland/deno · warning
Failed to extract with
Error message
Failed to extract with ${propagator.constructor.name}. What it means
The extract twin of the inject warning in ext/telemetry/telemetry.ts: CompositePropagator.extract reduces over registered propagators, and any propagator that throws while parsing incoming headers is reduced to this warning; the reduce then returns the previous context (line 1825), so extraction silently degrades to no propagated trace. Requests continue, but spans will not be correlated with the upstream.
Solutions
- Log and inspect the exact incoming traceparent/b3 headers when the warning appears; wrong length or non-hex characters are the usual culprit
- Validate/strip malformed tracing headers at your edge middleware before otel extraction sees them
- If a custom propagator is registered, harden its extract to return the input context instead of throwing on bad input
- Upgrade Deno if the headers are well-formed and the vendored propagator still throws
Example fix
// before: malformed header reaches extraction, warning logged, trace context lost
const ctx = propagator.extract(ROOT_CONTEXT, request.headers);
// after: gate extraction on a format check
const tp = request.headers.get("traceparent") ?? "";
const ctx = /^\d{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(tp.toLowerCase())
? propagator.extract(ROOT_CONTEXT, request.headers)
: ROOT_CONTEXT; Defensive patterns
Strategy: validation
Validate before calling
// drop malformed tracing headers before otel ever parses them
const TRACEPARENT = /^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/;
export function extractContext(ctx: Context, headers: Headers): Context {
const tp = headers.get("traceparent");
if (tp && !TRACEPARENT.test(tp.toLowerCase())) return ctx; // malformed -> start fresh trace
return propagator.extract(ctx, headers);
} Type guard
function isTraceparent(h: string | null): boolean {
return !!h && /^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(h.toLowerCase());
} Prevention
- Reject or strip malformed traceparent/b3 headers in edge middleware before extraction
- Never generate your own traceparent strings; use the SDK
- Check for proxies/LBs that truncate or mangle distributed-tracing headers
- Remember a warned extract returns the prior context: requests proceed but traces silently split
When it happens
Trigger: An incoming carrier (typically request headers) carries a malformed traceparent, tracestate, or b3/b3-multi header that makes a propagator's extract throw; or a custom registered propagator throws on the getter/carrier combination. Note the W3C propagator usually ignores unparseable headers, so a throw typically implicates custom propagators or SDK bugs.
Common situations: Upstream services or load balancers generating non-compliant traceparent values (wrong lengths, non-hex chars, extra spaces); hand-set tracing headers in test fixtures; proxies that truncate or mangle distributed-tracing headers; mixing b3 and W3C formats across services.
Related errors
- Failed to inject with
- startActiveSpan requires a function argument
- TracerProvider can not be constructed
- ContextManager can not be constructed
- Counter can only be incremented
AI-assisted analysis of denoland/deno@a961cdec3b (2026-08-20).
Data as JSON: /api/errors/2d99c0e5f4248cb5.
Report an issue: GitHub.
Appendix: source
Thrown at ext/telemetry/telemetry.ts:1843
try {
propagator.inject(context, carrier, setter);
} catch (err) {
// deno-lint-ignore no-console
console.warn(
`Failed to inject with ${propagator.constructor.name}.`,
err,
);
}
}
}
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
return ArrayPrototypeReduce(this.#propagators, (ctx, propagator) => {
try {
return propagator.extract(ctx, carrier, getter);
} catch (err) {
// deno-lint-ignore no-console
console.warn(
`Failed to extract with ${propagator.constructor.name}.`,
err,
);
}
return ctx;
}, context);
}
fields(): string[] {
return ArrayPrototypeSlice(this.#fields);
}
}
let builtinTracerCache: Tracer;
function builtinTracer(): Tracer {
if (!builtinTracerCache) {
builtinTracerCache = new Tracer(OtelTracer.builtin());View on GitHub (pinned to a961cdec3b)