mirror of https://github.com/buster-so/buster.git
added additional logs to basic config
update package versions
This commit is contained in:
parent
89dbc2afb2
commit
16b0c275e5
|
@ -95,17 +95,17 @@
|
||||||
"@supabase/supabase-js": "catalog:",
|
"@supabase/supabase-js": "catalog:",
|
||||||
"@t3-oss/env-core": "^0.13.8",
|
"@t3-oss/env-core": "^0.13.8",
|
||||||
"@tailwindcss/vite": "^4.1.13",
|
"@tailwindcss/vite": "^4.1.13",
|
||||||
"@tanstack/db": "^0.2.5",
|
"@tanstack/db": "^0.3.0",
|
||||||
"@tanstack/match-sorter-utils": "^8.19.4",
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
||||||
"@tanstack/query-async-storage-persister": "^5.87.4",
|
"@tanstack/query-async-storage-persister": "^5.89.0",
|
||||||
"@tanstack/query-db-collection": "0.2.17",
|
"@tanstack/query-db-collection": "0.2.18",
|
||||||
"@tanstack/query-sync-storage-persister": "^5.87.4",
|
"@tanstack/query-sync-storage-persister": "^5.89.0",
|
||||||
"@tanstack/react-db": "0.1.18",
|
"@tanstack/react-db": "0.1.19",
|
||||||
"@tanstack/react-devtools": "^0.6.7",
|
"@tanstack/react-devtools": "^0.6.7",
|
||||||
"@tanstack/react-form": "^1.20.0",
|
"@tanstack/react-form": "^1.21.1",
|
||||||
"@tanstack/react-query": "^5.87.4",
|
"@tanstack/react-query": "^5.89.0",
|
||||||
"@tanstack/react-query-devtools": "^5.87.4",
|
"@tanstack/react-query-devtools": "^5.89.0",
|
||||||
"@tanstack/react-query-persist-client": "^5.87.4",
|
"@tanstack/react-query-persist-client": "^5.89.0",
|
||||||
"@tanstack/react-router": "^1.131.44",
|
"@tanstack/react-router": "^1.131.44",
|
||||||
"@tanstack/react-router-devtools": "^1.131.44",
|
"@tanstack/react-router-devtools": "^1.131.44",
|
||||||
"@tanstack/react-router-ssr-query": "^1.131.44",
|
"@tanstack/react-router-ssr-query": "^1.131.44",
|
||||||
|
@ -117,15 +117,15 @@
|
||||||
"@tanstack/router-plugin": "^1.131.44",
|
"@tanstack/router-plugin": "^1.131.44",
|
||||||
"@tanstack/store": "^0.7.5",
|
"@tanstack/store": "^0.7.5",
|
||||||
"@testing-library/jest-dom": "^6.8.0",
|
"@testing-library/jest-dom": "^6.8.0",
|
||||||
"@tiptap/core": "^3.4.3",
|
"@tiptap/core": "^3.4.4",
|
||||||
"@tiptap/extension-document": "^3.4.3",
|
"@tiptap/extension-document": "^3.4.4",
|
||||||
"@tiptap/extension-mention": "^3.4.3",
|
"@tiptap/extension-mention": "^3.4.4",
|
||||||
"@tiptap/extension-paragraph": "^3.4.3",
|
"@tiptap/extension-paragraph": "^3.4.4",
|
||||||
"@tiptap/extension-text": "^3.4.3",
|
"@tiptap/extension-text": "^3.4.4",
|
||||||
"@tiptap/pm": "^3.4.3",
|
"@tiptap/pm": "^3.4.4",
|
||||||
"@tiptap/react": "^3.4.3",
|
"@tiptap/react": "^3.4.4",
|
||||||
"@tiptap/starter-kit": "^3.4.3",
|
"@tiptap/starter-kit": "^3.4.4",
|
||||||
"@tiptap/suggestion": "^3.4.3",
|
"@tiptap/suggestion": "^3.4.4",
|
||||||
"@udecode/cn": "^49.0.15",
|
"@udecode/cn": "^49.0.15",
|
||||||
"@uploadthing/react": "^7.3.3",
|
"@uploadthing/react": "^7.3.3",
|
||||||
"axios": "catalog:",
|
"axios": "catalog:",
|
||||||
|
@ -140,7 +140,7 @@
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"dayjs": "^1.11.18",
|
"dayjs": "^1.11.18",
|
||||||
"font-color-contrast": "^11.1.0",
|
"font-color-contrast": "^11.1.0",
|
||||||
"framer-motion": "^12.23.12",
|
"framer-motion": "^12.23.13",
|
||||||
"fuse.js": "^7.1.0",
|
"fuse.js": "^7.1.0",
|
||||||
"html2canvas-pro": "^1.5.11",
|
"html2canvas-pro": "^1.5.11",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
|
@ -206,7 +206,7 @@
|
||||||
"@types/react": "catalog:",
|
"@types/react": "catalog:",
|
||||||
"@types/react-dom": "catalog:",
|
"@types/react-dom": "catalog:",
|
||||||
"@types/react-mentions": "^4.4.1",
|
"@types/react-mentions": "^4.4.1",
|
||||||
"@vitejs/plugin-react": "^5.0.2",
|
"@vitejs/plugin-react": "^5.0.3",
|
||||||
"@vitest/browser": "3.2.4",
|
"@vitest/browser": "3.2.4",
|
||||||
"@vitest/coverage-v8": "3.2.4",
|
"@vitest/coverage-v8": "3.2.4",
|
||||||
"@vitest/ui": "3.2.4",
|
"@vitest/ui": "3.2.4",
|
||||||
|
|
|
@ -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,
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { isServer } from '@tanstack/react-query';
|
import { isServer } from '@tanstack/react-query';
|
||||||
import type { AxiosRequestHeaders } from 'axios';
|
import type { AxiosRequestHeaders } from 'axios';
|
||||||
import axios, { type AxiosError, type InternalAxiosRequestConfig } 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 { Route as AuthRoute } from '@/routes/auth.login';
|
||||||
import { checkTokenValidity } from './auth_helpers/check-token-validity';
|
|
||||||
import { BASE_URL_V2 } from './config';
|
import { BASE_URL_V2 } from './config';
|
||||||
import { rustErrorHandler } from './errors';
|
import { rustErrorHandler } from './errors';
|
||||||
import { getSupabaseSessionServerFn } from './server-functions/getSupabaseSession';
|
|
||||||
|
|
||||||
const AXIOS_TIMEOUT = 120000; // 2 minutes
|
const AXIOS_TIMEOUT = 120000; // 2 minutes
|
||||||
|
|
||||||
|
@ -62,37 +61,21 @@ export const createAxiosInstance = (baseURL = BASE_URL_V2) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultAxiosRequestHandler = async (config: InternalAxiosRequestConfig<unknown>) => {
|
export const defaultAxiosRequestHandler = async (config: InternalAxiosRequestConfig<unknown>) => {
|
||||||
let token: string | undefined = '';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isServer) {
|
console.log('basic config', {
|
||||||
try {
|
url: config.url,
|
||||||
const sessionResponse = await getSupabaseSessionServerFn();
|
method: config.method,
|
||||||
token = sessionResponse?.data?.accessToken;
|
headers: config.headers,
|
||||||
} catch (supabaseError) {
|
data: config.data,
|
||||||
// Handle headers already sent error gracefully
|
params: config.params,
|
||||||
if (
|
baseURL: config.baseURL,
|
||||||
supabaseError instanceof Error &&
|
timeout: config.timeout,
|
||||||
supabaseError.message.includes('ERR_HTTP_HEADERS_SENT')
|
});
|
||||||
) {
|
const session = await getSupabaseSession();
|
||||||
console.warn('Headers already sent when getting auth token, proceeding without token');
|
const { accessToken: token } = session;
|
||||||
// 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 || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
// Log warning but don't throw - let the request proceed and handle auth errors in response interceptor
|
console.warn('No token found');
|
||||||
console.warn('No auth token available for request');
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(config.headers as AxiosRequestHeaders).Authorization = `Bearer ${token}`;
|
(config.headers as AxiosRequestHeaders).Authorization = `Bearer ${token}`;
|
||||||
|
|
|
@ -25,6 +25,7 @@ export const extractSimplifiedSupabaseSession = async (
|
||||||
|
|
||||||
export const getSupabaseSessionServerFn = createServerFn({ method: 'GET' }).handler(async () => {
|
export const getSupabaseSessionServerFn = createServerFn({ method: 'GET' }).handler(async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('getSupabaseSessionServerFn');
|
||||||
const supabase = getSupabaseServerClient();
|
const supabase = getSupabaseServerClient();
|
||||||
const { data, error } = await extractSimplifiedSupabaseSession(supabase);
|
const { data, error } = await extractSimplifiedSupabaseSession(supabase);
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import type { AuthError } from '@supabase/supabase-js';
|
|
||||||
import { isTokenAlmostExpired } from '@/api/auth_helpers/expiration-helpers';
|
|
||||||
import {
|
import {
|
||||||
extractSimplifiedSupabaseSession,
|
extractSimplifiedSupabaseSession,
|
||||||
getSupabaseSessionServerFn,
|
getSupabaseSessionServerFn,
|
||||||
getSupabaseUserServerFn,
|
getSupabaseUserServerFn,
|
||||||
} from '@/api/server-functions/getSupabaseSession';
|
} from '@/api/server-functions/getSupabaseSession';
|
||||||
import { isServer } from '@/lib/window';
|
import { isServer } from '@/lib/window';
|
||||||
import { getSupabaseCookieClient } from '../../api/auth_helpers/cookie-helpers';
|
|
||||||
import { getBrowserClient } from './client';
|
import { getBrowserClient } from './client';
|
||||||
|
|
||||||
const supabase = getBrowserClient();
|
const supabase = getBrowserClient();
|
||||||
|
@ -19,6 +16,7 @@ export type SimplifiedSupabaseSession = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSupabaseSession = async (): Promise<SimplifiedSupabaseSession> => {
|
export const getSupabaseSession = async (): Promise<SimplifiedSupabaseSession> => {
|
||||||
|
console.log('getSupabaseSession', isServer ? 'server' : 'client');
|
||||||
const { data: sessionData, error: sessionError } = isServer
|
const { data: sessionData, error: sessionError } = isServer
|
||||||
? await getSupabaseSessionServerFn()
|
? await getSupabaseSessionServerFn()
|
||||||
: await extractSimplifiedSupabaseSession(supabase);
|
: await extractSimplifiedSupabaseSession(supabase);
|
||||||
|
|
|
@ -31,13 +31,14 @@ export const Route = createFileRoute('/app')({
|
||||||
loader: async ({ context }) => {
|
loader: async ({ context }) => {
|
||||||
const { queryClient, supabaseSession } = context;
|
const { queryClient, supabaseSession } = context;
|
||||||
try {
|
try {
|
||||||
await Promise.all([prefetchGetMyUserInfo(queryClient)]);
|
// Use the session from context instead of fetching again
|
||||||
|
|
||||||
if (!supabaseSession?.accessToken) {
|
if (!supabaseSession?.accessToken) {
|
||||||
console.error('Session not found - redirecting to login');
|
console.error('Session not found - redirecting to login');
|
||||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 307 });
|
throw redirect({ to: '/auth/login', replace: true, statusCode: 307 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all([prefetchGetMyUserInfo(queryClient)]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
supabaseSession,
|
supabaseSession,
|
||||||
};
|
};
|
||||||
|
|
693
pnpm-lock.yaml
693
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,8 @@ packages:
|
||||||
- apps/cli
|
- apps/cli
|
||||||
- apps/web
|
- apps/web
|
||||||
|
|
||||||
|
minimumReleaseAge: 1440
|
||||||
|
|
||||||
catalog:
|
catalog:
|
||||||
'@aws-sdk/client-s3': ^3.888.0
|
'@aws-sdk/client-s3': ^3.888.0
|
||||||
'@aws-sdk/s3-request-presigner': ^3.888.0
|
'@aws-sdk/s3-request-presigner': ^3.888.0
|
||||||
|
|
Loading…
Reference in New Issue