-
Notifications
You must be signed in to change notification settings - Fork 360
fix: remove event emitter leak warning #7201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.
Overall package sizeSelf size: 4.38 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 |
BenchmarksBenchmark execution time: 2026-01-09 20:51:04 Comparing candidate commit 3170098 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics. |
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
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.
This is done by limiting the connect listeners added to one instead of up to three.
It also changes many listeners to become
oncelisteners instead ofonto limit the addition to a single execution, if sufficient.The code is also changed that only a single
beforeExitlistener is added. That is done by using a globalsymbol 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