Skip to content

fix(bcode-laminar): track pending flushes so shutdown awaits in-flight OTLP exports#80

Merged
Alezander9 merged 1 commit into
mainfrom
alex/v4-wait-pending-flushes
May 17, 2026
Merged

fix(bcode-laminar): track pending flushes so shutdown awaits in-flight OTLP exports#80
Alezander9 merged 1 commit into
mainfrom
alex/v4-wait-pending-flushes

Conversation

@Alezander9
Copy link
Copy Markdown
Member

@Alezander9 Alezander9 commented May 17, 2026

rc5 diagnostic confirmed root cause: session.idle's await processor.forceFlush() never returns because the in-flight OTLP HTTP export is killed by process.exit before it can resolve. The host doesn't track these Promises (they're orphan microtasks).Fix: bus event handlers now call trackFlush(processor.forceFlush()) which stores each Promise in a module-local pendingFlushes Set. The sync shutdown hook awaits Promise.all(pendingFlushes) before returning, so the host's 3s race actually waits for the in-flight HTTP request to complete.This is the actual fix the previous five rcs were chasing.


Summary by cubic

Ensure bcode-laminar waits for in-flight OTLP exports on shutdown so spans aren’t dropped. We now track flush Promises from bus handlers and await them within the host’s 3s shutdown window.

  • Bug Fixes
    • Track every processor.forceFlush() from bus events in a pendingFlushes Set via trackFlush.
    • Shutdown ends open spans, triggers a final forceFlush, then awaits Promise.all(pendingFlushes) (still bounded by the host race).
    • Improved stderr logs with counts and timings to confirm the path executed.

Written for commit 08d37e4. Summary will update on new commits. Review in cubic

…t OTLP exports

rc5 confirmed the issue: session.idle's await processor.forceFlush() never returns (no completion log printed) because the in-flight OTLP HTTP export is killed by process.exit before it can resolve. The host doesn't track these Promises because they're orphan microtasks from its perspective.

Fix: track every processor.forceFlush() call kicked off by bus event handlers (session.idle, session.deleted) in a module-local pendingFlushes Set. The sync shutdown hook now awaits Promise.all(pendingFlushes) before returning, so the host's 3s race actually waits for the in-flight HTTP request to complete.

trackFlush() wraps each Promise with .catch + .finally(delete) so failures don't leak and resolved entries are cleaned up. The shutdown hook itself also fires a final forceFlush to drain any spans the bus handlers haven't gotten to yet (defense in depth).
@Alezander9 Alezander9 merged commit 594023b into main May 17, 2026
@Alezander9 Alezander9 deleted the alex/v4-wait-pending-flushes branch May 17, 2026 18:35
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