fix(bcode-laminar): track pending flushes so shutdown awaits in-flight OTLP exports#80
Merged
Merged
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-laminarwaits 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.processor.forceFlush()from bus events in apendingFlushesSet viatrackFlush.forceFlush, then awaitsPromise.all(pendingFlushes)(still bounded by the host race).Written for commit 08d37e4. Summary will update on new commits. Review in cubic