Skip to content

fix: [AI-190] prevent tracing exporter timeout from leaking timers#191

Merged
anandgupta42 merged 1 commit intomainfrom
fix/tracing-exporter-timeout
Mar 16, 2026
Merged

fix: [AI-190] prevent tracing exporter timeout from leaking timers#191
anandgupta42 merged 1 commit intomainfrom
fix/tracing-exporter-timeout

Conversation

@anandgupta42
Copy link
Contributor

What does this PR do?

Fixes the withTimeout helper in Tracer.endTrace() to properly clean up setTimeout timers, preventing the Node.js/Bun event loop from hanging for 5 seconds after every trace export. Also adds timeout logging for observability and aligns the HttpExporter internal timeout with the per-exporter wrapper.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #190

How did you verify your code works?

  • All 39 adversarial tracing tests pass (bun test test/altimate/tracing-adversarial.test.ts)
  • Timeout warning log verified in test output: [tracing] Exporter "hanging" timed out after 5000ms
  • TypeScript typecheck passes via turbo
  • 6-model consensus code review (Claude, GPT 5.2 Codex, Gemini 3.1 Pro, Kimi K2.5, MiniMax M2.5, GLM-5) — unanimous approval

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

Changes:

  • Add clearTimeout in .finally() to withTimeout so the event loop exits immediately after endTrace() instead of hanging for 5 seconds
  • Log a console.warn when an exporter times out (uses the previously unused name parameter for diagnostics)
  • Align HttpExporter internal AbortSignal.timeout from 10s to 5s to match the per-exporter wrapper timeout
  • Clean up safety-net timer in adversarial test to prevent open handles

🤖 Generated with Claude Code

- Add `clearTimeout` in `.finally()` to `withTimeout` so the event loop
  exits immediately after `endTrace()` instead of hanging for 5 seconds
- Log a `console.warn` when an exporter times out (uses the previously
  unused `name` parameter for diagnostics)
- Align `HttpExporter` internal `AbortSignal.timeout` from 10s to 5s to
  match the per-exporter wrapper timeout
- Clean up safety-net timer in adversarial test to prevent open handles

Closes #190

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42 anandgupta42 merged commit 9b15aa2 into main Mar 16, 2026
9 checks passed
anandgupta42 added a commit that referenced this pull request Mar 17, 2026
)

- Add `clearTimeout` in `.finally()` to `withTimeout` so the event loop
  exits immediately after `endTrace()` instead of hanging for 5 seconds
- Log a `console.warn` when an exporter times out (uses the previously
  unused `name` parameter for diagnostics)
- Align `HttpExporter` internal `AbortSignal.timeout` from 10s to 5s to
  match the per-exporter wrapper timeout
- Clean up safety-net timer in adversarial test to prevent open handles

Closes #190

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42 anandgupta42 deleted the fix/tracing-exporter-timeout branch March 17, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: tracing exporter timeout leaks timers and blocks process exit

1 participant