Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): drop Chrome extension port lastError from Sentry (#17198)

cursor[bot]a449eb97cdeb
diff --git a/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md b/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
index 1ea5b4af03..944bc94d79 100644
--- a/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
+++ b/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
@@ -142,7 +142,10 @@ The recurring shapes and their correct disposition:
render user URLs as native `<a>`, not a framework `<Link>` (#15245).
- **Perf detectors / third-party** — N+1, HTTP-overhead `info` issues, browser
extensions, crawlers. → Sentry project settings (inbound filters, detectors),
- not code.
+ not code. Stackless Chrome `chrome.runtime` lastError
+ (`Could not establish connection. Receiving end does not exist`) is the
+ exception: `denyUrls` cannot match with no frames, so a named predicate
+ drops it (LANGFUSE-614).
- **Stale-deploy** — chunk 404s, `importScripts` failures, version-skew. → a
reload-on-new-version prompt + release-aware handling (open work).
diff --git a/web/src/utils/sentryFilters.clienttest.ts b/web/src/utils/sentryFilters.clienttest.ts
index 875b3a2a91..1c91b3da13 100644
--- a/web/src/utils/sentryFilters.clienttest.ts
+++ b/web/src/utils/sentryFilters.clienttest.ts
@@ -740,6 +740,68 @@ describe("isDenylistedNoiseEvent", () => {
});
});
+ describe("I. drops Chrome extension port lastError (no stack, so denyUrls misses them)", () => {
+ // Real shape (LANGFUSE-614): Chrome rejects `chrome.runtime.sendMessage`
+ // / `connect` when the extension background or content-script port is
+ // gone. Unhandled rejection, no frames, so denyUrls never matches.
+ const chromeExtensionPortEvent = (
+ value: string,
+ mechanismType = "auto.browser.global_handlers.onunhandledrejection",
+ ): ErrorEvent =>
+ ({
+ exception: {
+ values: [
+ {
+ type: "Error",
+ value,
+ mechanism: { type: mechanismType, handled: false },
+ },
+ ],
+ },
+ }) as ErrorEvent;
+
+ it("drops the LANGFUSE-614 receiving-end lastError", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ chromeExtensionPortEvent(
+ "Could not establish connection. Receiving end does not exist.",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the same wording without a trailing period", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ chromeExtensionPortEvent(
+ "Could not establish connection. Receiving end does not exist",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the sibling Chrome lastError for a closed message port", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ chromeExtensionPortEvent(
+ "The message port closed before a response was received.",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the same wording via a global onerror handler", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ chromeExtensionPortEvent(
+ "Could not establish connection. Receiving end does not exist.",
+ "auto.browser.global_handlers.onerror",
+ ),
+ ),
+ ).toBe(true);
+ });
+ });
+
// The heart of the safety contract: prove that real / similar-looking errors
// are NOT dropped. If any of these regress to `true`, a real bug would be
// hidden from Sentry.
@@ -1201,6 +1263,50 @@ describe("isDenylistedNoiseEvent", () => {
expect(isDenylistedNoiseEvent(event)).toBe(false);
});
+ it("keeps an app-captured Chrome port lastError (not a Sentry browser wrap)", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ exceptionEvent(
+ "Could not establish connection. Receiving end does not exist.",
+ ),
+ ),
+ ).toBe(false);
+ const consoleCaptured = {
+ exception: {
+ values: [
+ {
+ type: "Error",
+ value:
+ "Could not establish connection. Receiving end does not exist.",
+ mechanism: {
+ type: "auto.core.capture_console",
+ handled: true,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(consoleCaptured)).toBe(false);
+ });
+ it("keeps a longer app message that merely quotes the Chrome port lastError", () => {
+ const event = {
+ exception: {
+ values: [
+ {
+ type: "Error",
+ value:
+ "Worker handshake failed: Could not establish connection. Receiving end does not exist.",
+ mechanism: {
+ type: "auto.browser.global_handlers.onunhandledrejection",
+ handled: false,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(event)).toBe(false);
+ });
+
it("keeps an event with no exception values", () => {
expect(
isDenylistedNoiseEvent({ message: "some message" } as ErrorEvent),
diff --git a/web/src/utils/sentryFilters.ts b/web/src/utils/sentryFilters.ts
index 3e20642b02..87341ef4bc 100644
--- a/web/src/utils/sentryFilters.ts
+++ b/web/src/utils/sentryFilters.ts
@@ -236,6 +236,21 @@ function isDataDocumentUrl(event: ErrorEvent): boolean {
return typeof taggedUrl === "string" && taggedUrl.startsWith("data:");
}
+/**
+ * Chrome's exact `chrome.runtime.sendMessage` / `chrome.runtime.connect`
+ * lastError when the extension background or content-script port is gone.
+ * Extensions inject this into the page; Langfuse never calls `chrome.runtime`.
+ * Observed as an unhandled rejection with no stack (LANGFUSE-614), so
+ * `denyUrls` cannot match. Whole-message only — an app error that merely
+ * quotes the phrase is longer and is KEPT.
+ *
+ * Stored without a trailing period because {@link coreMessage} strips one.
+ */
+const CHROME_EXTENSION_PORT_MESSAGES: readonly string[] = [
+ "Could not establish connection. Receiving end does not exist",
+ "The message port closed before a response was received",
+];
+
/**
* A `TRPCClientError` re-wraps its cause's message. Depending on capture path
* the Sentry `value` may be the bare cause message (`Failed to fetch`) or carry
@@ -481,17 +496,26 @@ export function isDenylistedNoiseEvent(event: ErrorEvent): boolean {
// Java bridge (LANGFUSE-60G: Chrome Mobile WebView, anonymous `batch`
// frames only).
//
- // Anchored to Chromium's exact wording (Java identifier method name) AND
- // a Sentry browser-API / global-handler mechanism so an app-captured
- // exception that merely quotes this phrase is KEPT. A first-party
- // TypeError from our own listener is also KEPT (different message).
+ // Chrome extension port lastError (LANGFUSE-614) is the same class of
+ // injected-browser artifact: Chromium's exact `chrome.runtime` wording,
+ // no stack, `denyUrls` cannot match. Sibling message is the other
+ // documented lastError for a torn-down extension port.
+ //
+ // Both are anchored to a Sentry browser-API / global-handler mechanism
+ // so an app-captured exception that merely quotes the phrase is KEPT.
const mechanismType = exception?.mechanism?.type;
if (
typeof mechanismType === "string" &&
- mechanismType.startsWith("auto.browser.") &&
- ANDROID_WEBVIEW_JAVA_BRIDGE_ERROR_RE.test(exceptionValue)
+ mechanismType.startsWith("auto.browser.")
) {
- return true;
+ if (ANDROID_WEBVIEW_JAVA_BRIDGE_ERROR_RE.test(exceptionValue)) {
+ return true;
+ }
+ if (
+ CHROME_EXTENSION_PORT_MESSAGES.includes(coreMessage(exceptionValue))
+ ) {
+ return true;
+ }
}
// Next.js App Router hydrates with