added additional logs to basic config

update package versions
This commit is contained in:
Nate Kelley 2025-09-17 09:37:21 -06:00
parent 89dbc2afb2
commit 16b0c275e5
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
8 changed files with 357 additions and 471 deletions

View File

@ -95,17 +95,17 @@
"@supabase/supabase-js": "catalog:",
"@t3-oss/env-core": "^0.13.8",
"@tailwindcss/vite": "^4.1.13",
"@tanstack/db": "^0.2.5",
"@tanstack/db": "^0.3.0",
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/query-async-storage-persister": "^5.87.4",
"@tanstack/query-db-collection": "0.2.17",
"@tanstack/query-sync-storage-persister": "^5.87.4",
"@tanstack/react-db": "0.1.18",
"@tanstack/query-async-storage-persister": "^5.89.0",
"@tanstack/query-db-collection": "0.2.18",
"@tanstack/query-sync-storage-persister": "^5.89.0",
"@tanstack/react-db": "0.1.19",
"@tanstack/react-devtools": "^0.6.7",
"@tanstack/react-form": "^1.20.0",
"@tanstack/react-query": "^5.87.4",
"@tanstack/react-query-devtools": "^5.87.4",
"@tanstack/react-query-persist-client": "^5.87.4",
"@tanstack/react-form": "^1.21.1",
"@tanstack/react-query": "^5.89.0",
"@tanstack/react-query-devtools": "^5.89.0",
"@tanstack/react-query-persist-client": "^5.89.0",
"@tanstack/react-router": "^1.131.44",
"@tanstack/react-router-devtools": "^1.131.44",
"@tanstack/react-router-ssr-query": "^1.131.44",
@ -117,15 +117,15 @@
"@tanstack/router-plugin": "^1.131.44",
"@tanstack/store": "^0.7.5",
"@testing-library/jest-dom": "^6.8.0",
"@tiptap/core": "^3.4.3",
"@tiptap/extension-document": "^3.4.3",
"@tiptap/extension-mention": "^3.4.3",
"@tiptap/extension-paragraph": "^3.4.3",
"@tiptap/extension-text": "^3.4.3",
"@tiptap/pm": "^3.4.3",
"@tiptap/react": "^3.4.3",
"@tiptap/starter-kit": "^3.4.3",
"@tiptap/suggestion": "^3.4.3",
"@tiptap/core": "^3.4.4",
"@tiptap/extension-document": "^3.4.4",
"@tiptap/extension-mention": "^3.4.4",
"@tiptap/extension-paragraph": "^3.4.4",
"@tiptap/extension-text": "^3.4.4",
"@tiptap/pm": "^3.4.4",
"@tiptap/react": "^3.4.4",
"@tiptap/starter-kit": "^3.4.4",
"@tiptap/suggestion": "^3.4.4",
"@udecode/cn": "^49.0.15",
"@uploadthing/react": "^7.3.3",
"axios": "catalog:",
@ -140,7 +140,7 @@
"cmdk": "^1.1.1",
"dayjs": "^1.11.18",
"font-color-contrast": "^11.1.0",
"framer-motion": "^12.23.12",
"framer-motion": "^12.23.13",
"fuse.js": "^7.1.0",
"html2canvas-pro": "^1.5.11",
"js-cookie": "^3.0.5",
@ -206,7 +206,7 @@
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@types/react-mentions": "^4.4.1",
"@vitejs/plugin-react": "^5.0.2",
"@vitejs/plugin-react": "^5.0.3",
"@vitest/browser": "3.2.4",
"@vitest/coverage-v8": "3.2.4",
"@vitest/ui": "3.2.4",

View File

@ -1,40 +0,0 @@
import { openErrorNotification } from '@/context/BusterNotifications';
import { getBrowserClient } from '@/integrations/supabase/client';
import { getSupabaseSession } from '@/integrations/supabase/getSupabaseUserClient';
import { isTokenAlmostExpired } from './expiration-helpers';
const supabase = getBrowserClient();
export const checkTokenValidity = async () => {
const { expiresAt, accessToken } = await getSupabaseSession();
if (isTokenAlmostExpired(expiresAt)) {
try {
const { data: refreshedSession, error: refreshedSessionError } =
await supabase.auth.refreshSession();
if (refreshedSessionError || !refreshedSession.session) {
throw refreshedSessionError || new Error('Failed to refresh session');
}
const refreshedAccessToken = refreshedSession.session.access_token;
return {
access_token: refreshedAccessToken,
isTokenValid: true,
};
} catch (e) {
console.error(e);
openErrorNotification({
title: 'Error validating your user authentication',
description: 'Please refresh the page and try again',
duration: 10 * 1000, //10 seconds
});
}
}
return {
access_token: accessToken,
isTokenValid: true,
};
};

View File

@ -1,11 +1,10 @@
import { isServer } from '@tanstack/react-query';
import type { AxiosRequestHeaders } from 'axios';
import axios, { type AxiosError, type InternalAxiosRequestConfig } from 'axios';
import { getSupabaseSession } from '@/integrations/supabase/getSupabaseUserClient';
import { Route as AuthRoute } from '@/routes/auth.login';
import { checkTokenValidity } from './auth_helpers/check-token-validity';
import { BASE_URL_V2 } from './config';
import { rustErrorHandler } from './errors';
import { getSupabaseSessionServerFn } from './server-functions/getSupabaseSession';
const AXIOS_TIMEOUT = 120000; // 2 minutes
@ -62,37 +61,21 @@ export const createAxiosInstance = (baseURL = BASE_URL_V2) => {
};
export const defaultAxiosRequestHandler = async (config: InternalAxiosRequestConfig<unknown>) => {
let token: string | undefined = '';
try {
if (isServer) {
try {
const sessionResponse = await getSupabaseSessionServerFn();
token = sessionResponse?.data?.accessToken;
} catch (supabaseError) {
// Handle headers already sent error gracefully
if (
supabaseError instanceof Error &&
supabaseError.message.includes('ERR_HTTP_HEADERS_SENT')
) {
console.warn('Headers already sent when getting auth token, proceeding without token');
// Continue without token rather than crashing
return config;
}
// For other errors, log but continue without token instead of throwing
console.warn('Failed to get auth token from Supabase:', supabaseError);
return config;
}
} else {
// Always check token validity before making requests
const tokenResult = await checkTokenValidity();
token = tokenResult?.access_token || '';
}
console.log('basic config', {
url: config.url,
method: config.method,
headers: config.headers,
data: config.data,
params: config.params,
baseURL: config.baseURL,
timeout: config.timeout,
});
const session = await getSupabaseSession();
const { accessToken: token } = session;
if (!token) {
// Log warning but don't throw - let the request proceed and handle auth errors in response interceptor
console.warn('No auth token available for request');
return config;
console.warn('No token found');
}
(config.headers as AxiosRequestHeaders).Authorization = `Bearer ${token}`;

View File

@ -25,6 +25,7 @@ export const extractSimplifiedSupabaseSession = async (
export const getSupabaseSessionServerFn = createServerFn({ method: 'GET' }).handler(async () => {
try {
console.log('getSupabaseSessionServerFn');
const supabase = getSupabaseServerClient();
const { data, error } = await extractSimplifiedSupabaseSession(supabase);
return {

View File

@ -1,12 +1,9 @@
import type { AuthError } from '@supabase/supabase-js';
import { isTokenAlmostExpired } from '@/api/auth_helpers/expiration-helpers';
import {
extractSimplifiedSupabaseSession,
getSupabaseSessionServerFn,
getSupabaseUserServerFn,
} from '@/api/server-functions/getSupabaseSession';
import { isServer } from '@/lib/window';
import { getSupabaseCookieClient } from '../../api/auth_helpers/cookie-helpers';
import { getBrowserClient } from './client';
const supabase = getBrowserClient();
@ -19,6 +16,7 @@ export type SimplifiedSupabaseSession = {
};
export const getSupabaseSession = async (): Promise<SimplifiedSupabaseSession> => {
console.log('getSupabaseSession', isServer ? 'server' : 'client');
const { data: sessionData, error: sessionError } = isServer
? await getSupabaseSessionServerFn()
: await extractSimplifiedSupabaseSession(supabase);

View File

@ -31,13 +31,14 @@ export const Route = createFileRoute('/app')({
loader: async ({ context }) => {
const { queryClient, supabaseSession } = context;
try {
await Promise.all([prefetchGetMyUserInfo(queryClient)]);
// Use the session from context instead of fetching again
if (!supabaseSession?.accessToken) {
console.error('Session not found - redirecting to login');
throw redirect({ to: '/auth/login', replace: true, statusCode: 307 });
}
await Promise.all([prefetchGetMyUserInfo(queryClient)]);
return {
supabaseSession,
};

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,8 @@ packages:
- apps/cli
- apps/web
minimumReleaseAge: 1440
catalog:
'@aws-sdk/client-s3': ^3.888.0
'@aws-sdk/s3-request-presigner': ^3.888.0