Skip to content

Commit 1a89f2e

Browse files
rustyconoverclaude
andcommitted
Fix trace context leakage for secondary workers
Secondary workers were restoring trace context twice: 1. From invocation.traceparent (correct - from client) 2. From init_input.traceparent (redundant - from primary worker) The second restore at line 1329 was problematic because: - The trace_token was never detached, causing context leakage - It overwrote the active context from invocation.traceparent - This could cause spans to not appear under the expected trace Since secondary workers already receive traceparent in the invocation (which is the same one the client sent), the restore from init_input is unnecessary. The init_input.traceparent is still stored for potential use by workers that don't receive traceparent in the invocation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9843f3b commit 1a89f2e

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

vgi/worker.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,15 +1321,11 @@ def _process_invocation(
13211321
tracing.VGI_EXECUTION_ID, exec_id.hex()
13221322
)
13231323

1324-
if (
1325-
instance.init_input is not None
1326-
and instance.init_input.traceparent is not None
1327-
):
1328-
# The traceparent is passed down from the global init.
1329-
trace_token = tracing.restore_trace_context(
1330-
instance.init_input.traceparent,
1331-
instance.init_input.tracestate,
1332-
)
1324+
# Note: Secondary workers already have trace context restored
1325+
# from invocation.traceparent (line 1458 in _run_loop), so we
1326+
# don't need to restore from init_input.traceparent here.
1327+
# The init_input.traceparent is stored for potential use by
1328+
# workers that don't receive traceparent in the invocation.
13331329

13341330
except (KeyboardInterrupt, SystemExit):
13351331
raise

0 commit comments

Comments
 (0)