Skip to content

chore(clerk-js): Remove non-actionable error from Session poller #5494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-numbers-sink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Remove non-actionable error from Session poller.
13 changes: 8 additions & 5 deletions packages/clerk-js/src/core/auth/AuthCookieService.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createCookieHandler } from '@clerk/shared/cookie';
import { setDevBrowserJWTInURL } from '@clerk/shared/devBrowser';
import { is4xxError, isClerkAPIResponseError, isClerkRuntimeError } from '@clerk/shared/error';
import { is4xxError, isClerkAPIResponseError, isClerkRuntimeError, isNetworkError } from '@clerk/shared/error';
import { noop } from '@clerk/shared/utils';
import type { Clerk, InstanceType } from '@clerk/types';

import { clerkCoreErrorTokenRefreshFailed, clerkMissingDevBrowserJwt } from '../errors';
import { clerkMissingDevBrowserJwt } from '../errors';
import { eventBus, events } from '../events';
import type { FapiClient } from '../fapiClient';
import type { ClientUatCookieHandler } from './cookies/clientUat';
Expand Down Expand Up @@ -181,18 +181,21 @@ export class AuthCookieService {
}

private handleGetTokenError(e: any) {
//throw if not a clerk api error (aka fapi error) and not a network error
if (!isClerkAPIResponseError(e) && !isClerkRuntimeError(e)) {
clerkCoreErrorTokenRefreshFailed(e.message || e);
//early return if not a clerk api error (aka fapi error) and not a network error
if (!isClerkAPIResponseError(e) && !isClerkRuntimeError(e) && !isNetworkError(e)) {
return;
}

//sign user out if a 4XX error
if (is4xxError(e)) {
void this.clerk.handleUnauthenticated().catch(noop);
return;
}

// --------
// Treat any other error as a noop
// TODO(debug-logs): Once debug logs is available log this error.
// --------
}

/**
Expand Down
4 changes: 0 additions & 4 deletions packages/clerk-js/src/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export function clerkMissingFapiClientInResources(): never {
throw new Error(`${errorPrefix} Missing FAPI client in resources.`);
}

export function clerkCoreErrorTokenRefreshFailed(message: string): never {
throw new Error(`${errorPrefix} Token refresh failed (error='${message}')`);
}

export function clerkOAuthCallbackDidNotCompleteSignInSignUp(type: 'sign in' | 'sign up'): never {
throw new Error(
`${errorPrefix} Something went wrong initializing Clerk during the ${type} flow. Please contact support.`,
Expand Down