completionId: cgen-6586e28a76354f0f80f494746ac41b3f

cgen-6586e28a76354f0f80f494746ac41b3f
This commit is contained in:
Builder.io 2025-11-10 02:56:03 +00:00
parent e945424d86
commit 17a751f897

View file

@ -862,39 +862,58 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
if (typeof window === "undefined") return; if (typeof window === "undefined") return;
const onAuthError = (ev: any) => { const onAuthError = (ev: any) => {
// Get message from various possible sources
const reason = ev?.reason || ev?.error || ev?.message || ev; const reason = ev?.reason || ev?.error || ev?.message || ev;
const message = String( const messageStr = String(
reason?.message ?? reason ?? ev?.toString?.() ?? "", reason?.message ?? reason ?? ev?.toString?.() ?? "",
).toLowerCase(); ).toLowerCase();
// IGNORE Discord SDK, Builder.io, and other non-auth errors // Also check the error source (for Builder errors)
if ( const source = String(ev?.filename || ev?.source || "").toLowerCase();
message.includes("agent source") || const fullMessage = messageStr + " " + source;
message.includes("discord") ||
message.includes("@discord") || // IGNORE non-auth errors from known sources:
message.includes("wix") || // - Discord SDK ("agent source", "discord", "@discord")
message.includes("frame_id") || // - Builder/CMS ("host", "read", "@import", "construct-stylesheets", "wix")
message.includes("cross-origin") || // - Cross-origin issues ("frame_id", "cross-origin")
message.includes("host validation") || // - Storage/misc issues
message.includes("host is not") || const nonAuthPatterns = [
message.includes("host is not supported") || "agent source",
message.includes("host is not valid") || "discord",
message.includes("insights whitelist") || "@discord",
message.includes("read -") || "wix",
message.includes("@import rules") || "frame_id",
message.includes("construct-stylesheets") "cross-origin",
) { "host validation",
"host is not",
"host is not supported",
"host is not valid",
"insights whitelist",
"read -",
"read event",
"@import rules",
"construct-stylesheets",
"quota exceeded",
"storage quota",
"security/strict-origin-when-cross-origin",
];
if (nonAuthPatterns.some((pattern) => fullMessage.includes(pattern))) {
// Just log but don't clear session // Just log but don't clear session
console.debug("Non-auth error (ignoring):", message); console.debug("Non-auth error (ignoring):", fullMessage);
return; return;
} }
// Only clear session for actual auth errors // Only clear session for actual auth errors
if ( const authErrorPatterns = [
message.includes("invalid refresh token") || "invalid refresh token",
message.includes("session expired") || "session expired",
message.includes("revoked") "revoked",
) { "unauthorized",
"auth/",
];
if (authErrorPatterns.some((pattern) => messageStr.includes(pattern))) {
console.warn("Captured auth error (clearing local session):", reason); console.warn("Captured auth error (clearing local session):", reason);
try { try {
clearClientAuthState(); clearClientAuthState();