Enrich listener leak error telemetry with kind and listenerCount#308897
Merged
bryanchen-d merged 9 commits intomainfrom Apr 14, 2026
Merged
Enrich listener leak error telemetry with kind and listenerCount#308897bryanchen-d merged 9 commits intomainfrom
bryanchen-d merged 9 commits intomainfrom
Conversation
…elemetry Introduce ErrorWithDiagProps base class that carries a diagProperties bag. ListenerLeakError and ListenerRefusalError now extend it, passing kind and listenerCount. BaseErrorTelemetry flattens diagProperties into the telemetry event via Object.assign, with no coupling to specific error types.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new error subtype to attach diagnostic properties to errors and updates error telemetry to flatten those diagnostics into UnhandledError events, with initial adoption in listener leak/refusal errors.
Changes:
- Introduces
ErrorWithDiagProps(diagPropertiesbag +is()guard) insrc/vs/base/common/errors.ts. - Updates
ListenerLeakError/ListenerRefusalErrorto extendErrorWithDiagPropsand populate{ kind, listenerCount }. - Updates
BaseErrorTelemetryto detectErrorWithDiagPropsandObject.assigndiagnostics onto the telemetry payload.
Show a summary per file
| File | Description |
|---|---|
| src/vs/base/common/errors.ts | Adds ErrorWithDiagProps for carrying diagnostic properties on errors. |
| src/vs/base/common/event.ts | Migrates listener leak/refusal errors to ErrorWithDiagProps and passes diagnostics. |
| src/vs/platform/telemetry/common/errorTelemetry.ts | Flattens diagnostic properties onto UnhandledError telemetry events. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/platform/telemetry/common/errorTelemetry.ts:129
- New behavior (copying diagnostic properties into the
UnhandledErrorpayload) isn’t covered by tests. There are existing error telemetry tests undersrc/vs/platform/telemetry/test/browser/telemetryService.test.ts; please add a test that throws anErrorWithDiagProps(or a subclass) and asserts the diagnostic fields are present in the logged event (and still go through PII cleaning).
const errorEvent: ErrorEvent = { msg, callstack };
// flatten diagnostic properties directly into the telemetry event
if (ErrorWithDiagProps.is(err)) {
Object.assign(errorEvent, err.diagProperties);
}
this._enqueue(errorEvent);
- Files reviewed: 3/3 changed files
- Comments generated: 2
- BaseErrorTelemetry: export ErrorEventFragment, add DiagLogger type and registerDiagLogger() for typed telemetry loggers keyed by Error.name - listenerLeakDiagTelemetry.ts: register GDPR-classified loggers for ListenerLeakError/ListenerRefusalError with kind and listenerCount - Wire side-effect import in browser, node, and electron-main errorTelemetry - ListenerLeakClassification extends ErrorEventFragment via intersection - Rename ErrorWithDiagProps to ErrorWithTelemetry
ErrorWithTelemetry.is() now falls back to duck-typing (checks for diagProperties own property on Error instances) when instanceof fails, making it safe across JS realm boundaries.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a generic mechanism for enriching unhandled error telemetry with structured diagnostic properties (with explicit GDPR classifications) so specific error types—starting with listener leak errors—can emit more useful triage data without hard-coupling the base telemetry pipeline to those error subclasses.
Changes:
- Introduces
ErrorWithTelemetryto carry adiagPropertiesbag alongside an error. - Extends listener leak/refusal errors to include
{ kind, listenerCount }diagnostics and makesBaseErrorTelemetryflatten these into the emitted event. - Adds a
DiagLoggerregistration mechanism and a listener-leak-specific registration module, activated via side-effect imports in platform-specific telemetry entrypoints.
Show a summary per file
| File | Description |
|---|---|
| src/vs/base/common/errors.ts | Adds ErrorWithTelemetry and a type guard for identifying telemetry-enriched errors. |
| src/vs/base/common/event.ts | Updates listener leak/refusal errors to extend ErrorWithTelemetry and attach kind/listenerCount. |
| src/vs/platform/telemetry/common/errorTelemetry.ts | Exports ErrorEventFragment, adds DiagLogger registry + flattening/dispatch logic for enriched error telemetry. |
| src/vs/platform/telemetry/common/listenerLeakDiagTelemetry.ts | New GDPR-typed publicLogError2 call sites for leak/refusal diagnostics via registered loggers. |
| src/vs/platform/telemetry/browser/errorTelemetry.ts | Side-effect import to activate listener leak diagnostic logger registration in browser builds. |
| src/vs/platform/telemetry/node/errorTelemetry.ts | Side-effect import to activate listener leak diagnostic logger registration in node builds. |
| src/vs/platform/telemetry/electron-main/errorTelemetry.ts | Side-effect import to activate listener leak diagnostic logger registration in electron-main builds. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 3
benvillalobos
approved these changes
Apr 13, 2026
benvillalobos
previously approved these changes
Apr 13, 2026
…rsection Avoids `local/code-no-any-casts` ESLint warnings that broke the Compile & Hygiene CI check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bhavyaus
approved these changes
Apr 14, 2026
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
Adds kind and listenerCount fields to ListenerLeakError / ListenerRefusalError so that the error telemetry pipeline can report why a leak was detected and how many listeners were active.
Changes
src/vs/base/common/event.ts
eadonly kind and
eadonly listenerCount fields, plus a static is() with instanceof + structural fallback for cross-realm safety
ame)
src/vs/platform/telemetry/common/errorTelemetry.ts
Telemetry
The UnhandledError event gains two optional fields when the error is a listener leak:
Non-leak errors are unaffected (fields absent).