Skip to content

Conversation

@BridgeAR
Copy link
Collaborator

@BridgeAR BridgeAR commented Jan 8, 2026

This is done by limiting the connect listeners added to one instead of up to three.

It also changes many listeners to become once listeners instead of on to limit the addition to a single execution, if sufficient.

The code is also changed that only a single beforeExit listener is added. That is done by using a global
symbol that may now contain different dd-trace related state.

In addition, this adds a test helper that verifies we are never above 6 listeners.
Exceptions are special handled (pino-pretty adds additional listeners).

Fixes: #7110

This is done by two steps: a) only add a single connect listener
instead of two and b) increase the limit by one to behave as if
there would be no limit.

The downside of the second part is that the user may check for this
value and would now get a different value than the originally
defined one.
@BridgeAR BridgeAR requested review from a team as code owners January 8, 2026 14:53
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Overall package size

Self size: 4.38 MB
Deduped: 5.21 MB
No deduping: 5.21 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter
Copy link

pr-commenter bot commented Jan 8, 2026

Benchmarks

Benchmark execution time: 2026-01-09 20:51:04

Comparing candidate commit 3170098 in PR branch BridgeAR/2026-01-08-fix-7110 with baseline commit d0cc613 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 58.33333% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.53%. Comparing base (d0cc613) to head (3170098).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/datadog-instrumentations/src/net.js 0.00% 12 Missing ⚠️
packages/dd-trace/src/openfeature/writers/base.js 0.00% 6 Missing ⚠️
packages/dd-trace/src/debugger/index.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7201      +/-   ##
==========================================
- Coverage   84.54%   84.53%   -0.02%     
==========================================
  Files         529      532       +3     
  Lines       22542    22643     +101     
==========================================
+ Hits        19058    19141      +83     
- Misses       3484     3502      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official

This comment has been minimized.

@BridgeAR BridgeAR marked this pull request as draft January 8, 2026 18:56
The event listeners added in many circumstances should only be used
once, so using once should be best.
This limits the usage of the beforeExit listeners by using a global
dd-trace symbol across the code and using a single set of handlers
that are run before the process exits.

In addition, reload dogstatsd in tests to limit adding too many
listeners there as well.

The newly added global may be used in multiple circumstances and
is a better abstraction than having multiple different symbols
that are added to the global.
This symbol is also non enumerable, non writable, and not configurable.
When instrumenting `ai`, we now use a WeakSet for tracking instances.
This prevents the need for adding a symbol to the tracer instances
to know if it has been instrumented or not.
@BridgeAR BridgeAR marked this pull request as ready for review January 9, 2026 20:05
@BridgeAR BridgeAR requested review from a team as code owners January 9, 2026 20:05
@BridgeAR BridgeAR requested review from khanayan123 and removed request for a team January 9, 2026 20:05
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.

[BUG]: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added to [TLSSocket].

2 participants