From dc92e72c7554cc447ae4f7757643cc646d7b8ff0 Mon Sep 17 00:00:00 2001 From: "vs-code-engineering[bot]" <122617954+vs-code-engineering[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 03:47:34 +0000 Subject: [PATCH] fix: surface underlying cause in ExtensionError for telemetry (fixes #321638) (#321645) Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Michael Lively <12552271+Yoyokrazy@users.noreply.github.com> --- src/vs/platform/extensions/common/extensions.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/extensions/common/extensions.ts b/src/vs/platform/extensions/common/extensions.ts index e26d74e2e63..6a8cc98d148 100644 --- a/src/vs/platform/extensions/common/extensions.ts +++ b/src/vs/platform/extensions/common/extensions.ts @@ -506,9 +506,16 @@ export class ExtensionError extends Error { readonly extension: ExtensionIdentifier; constructor(extensionIdentifier: ExtensionIdentifier, cause: Error, message?: string) { - super(`Error in extension ${ExtensionIdentifier.toKey(extensionIdentifier)}: ${message ?? cause.message}`, { cause }); + const detail = message && cause?.message ? `${message}: ${cause.message}` : (message ?? cause?.message); + super(`Error in extension ${ExtensionIdentifier.toKey(extensionIdentifier)}: ${detail}`, { cause }); this.name = 'ExtensionError'; this.extension = extensionIdentifier; + // Adopt the underlying cause's stack so error telemetry buckets by the real + // failure site inside the extension instead of the generic event-dispatch + // frames. Extension attribution relies on `this.extension`, not this stack. + if (cause?.stack) { + this.stack = cause.stack; + } } }