fix: finish spans when decorated methods throw - #49
Open
seandearnaley wants to merge 1 commit into
Open
Conversation
seandearnaley
force-pushed
the
fix/dd-trace-v6-peer
branch
from
August 31, 2026 01:13
969d27d to
777c473
Compare
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.
Summary
Problem
recordException()previously tagged and immediately rethrew the error. In the synchronous catch path, that made the followingspan.finish()unreachable and left the span open. Promise paths happened to finish through.finally(), but their error propagation depended on the helper throwing.This change makes
recordException()responsible only for tagging. Each caller now explicitly propagates the original error, after the synchronous path has finalized its span; asynchronous paths continue to finalize through.finally().This is a lifecycle bug fix for the package's existing
dd-trace ^5support. It intentionally does not change the peer range, development dependency, Node.js CI version, or lockfile.Verification
npm test -- --runInBand— 2 suites, 20 tests passednpm run buildESLINT_USE_FLAT_CONFIG=false npx eslint src/decorator.injector.ts src/decorator.injector.spec.ts --no-fixsrc/datadog-trace.module.tsandsrc/datadog-trace.module.spec.ts