Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Add more Sentry filtering (#2556)

Abimael Martell79f2d7b573a1
diff --git a/apps/api/src/services/sentry.ts b/apps/api/src/services/sentry.ts
index abc5a97d8..349f5b683 100644
--- a/apps/api/src/services/sentry.ts
+++ b/apps/api/src/services/sentry.ts
@@ -5,6 +5,7 @@ import {
AddFeatureError,
RemoveFeatureError,
} from "../scraper/scrapeURL/error";
+import { AbortManagerThrownError } from "../scraper/scrapeURL/lib/abortManager";
type CaptureContext = {
tags?: Record<string, string>;
@@ -57,15 +58,24 @@ if (config.SENTRY_DSN) {
const error = hint?.originalException;
if (error && typeof error === "object") {
- // Filter out AddFeatureError and RemoveFeatureError
if (
error instanceof AddFeatureError ||
- error instanceof RemoveFeatureError
+ error instanceof RemoveFeatureError ||
+ error instanceof AbortManagerThrownError
) {
return null;
}
- const errorCode = "code" in error ? String(error.code) : "";
+ // We sometimes rethrow TransportableErrors across process boundaries as a
+ // plain Error with message like `${code}|${json}` (see error-serde.ts).
+ // In that case, `error.code` is missing, so extract it from the message.
+ const errorCodeFromField = "code" in error ? String(error.code) : "";
+ const errorMessage =
+ error instanceof Error ? String(error.message || "") : "";
+ const errorCodeFromMessage =
+ errorCodeFromField ||
+ (errorMessage.includes("|") ? errorMessage.split("|", 1)[0] : "");
+ const errorCode = errorCodeFromMessage;
const transportableErrorCodes = [
"SCRAPE_ALL_ENGINES_FAILED",