mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
Merge pull request #922 from mvanhorn/osc/904-console-log-guard
fix: gate console.log calls behind development check
This commit is contained in:
commit
3776d3d6bc
3 changed files with 14 additions and 8 deletions
|
|
@ -33,6 +33,8 @@ import { z } from "zod";
|
|||
import type { MCPServerConfig, MCPToolDefinition } from "@/contracts/types/mcp.types";
|
||||
import { connectorsApiService } from "@/lib/apis/connectors-api.service";
|
||||
|
||||
const IS_DEV = process.env.NODE_ENV === "development";
|
||||
|
||||
/**
|
||||
* Zod schema for MCP server configuration
|
||||
* Supports both stdio (local process) and HTTP (remote server) transports
|
||||
|
|
@ -102,11 +104,11 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
|
|||
// Check cache first
|
||||
const cached = configCache.get(configJson);
|
||||
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
|
||||
console.log("[MCP Validator] ✅ Using cached config");
|
||||
if (IS_DEV) console.log("[MCP Validator] ✅ Using cached config");
|
||||
return { config: cached.config, error: null };
|
||||
}
|
||||
|
||||
console.log("[MCP Validator] 🔍 Parsing new config...");
|
||||
if (IS_DEV) console.log("[MCP Validator] 🔍 Parsing new config...");
|
||||
|
||||
// Clean up expired cache entries periodically
|
||||
if (configCache.size > 100) {
|
||||
|
|
@ -176,7 +178,7 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
|
|||
timestamp: Date.now(),
|
||||
});
|
||||
|
||||
console.log("[MCP Validator] ✅ Config parsed successfully:", config);
|
||||
if (IS_DEV) console.log("[MCP Validator] ✅ Config parsed successfully:", config);
|
||||
|
||||
return {
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import {
|
|||
} from "@/lib/electric/client";
|
||||
import { ElectricContext } from "@/lib/electric/context";
|
||||
|
||||
const IS_DEV = process.env.NODE_ENV === "development";
|
||||
|
||||
interface ElectricProviderProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
|
@ -40,7 +42,7 @@ export function ElectricProvider({ children }: ElectricProviderProps) {
|
|||
// No user logged in - cleanup if previous user existed
|
||||
if (!isUserLoaded || !user?.id) {
|
||||
if (previousUserIdRef.current && isElectricInitialized()) {
|
||||
console.log("[ElectricProvider] User logged out, cleaning up...");
|
||||
if (IS_DEV) console.log("[ElectricProvider] User logged out, cleaning up...");
|
||||
cleanupElectric().then(() => {
|
||||
previousUserIdRef.current = null;
|
||||
setElectricClient(null);
|
||||
|
|
@ -61,14 +63,14 @@ export function ElectricProvider({ children }: ElectricProviderProps) {
|
|||
|
||||
async function init() {
|
||||
try {
|
||||
console.log(`[ElectricProvider] Initializing for user: ${userId}`);
|
||||
if (IS_DEV) console.log(`[ElectricProvider] Initializing for user: ${userId}`);
|
||||
const client = await initElectric(userId);
|
||||
|
||||
if (mounted) {
|
||||
previousUserIdRef.current = userId;
|
||||
setElectricClient(client);
|
||||
setError(null);
|
||||
console.log(`[ElectricProvider] ✅ Ready for user: ${userId}`);
|
||||
if (IS_DEV) console.log(`[ElectricProvider] ✅ Ready for user: ${userId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[ElectricProvider] Failed to initialize:", err);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
|||
import type { SyncHandle } from "@/lib/electric/client";
|
||||
import { useElectricClient } from "@/lib/electric/context";
|
||||
|
||||
const IS_DEV = process.env.NODE_ENV === "development";
|
||||
|
||||
/**
|
||||
* Hook for managing connectors with Electric SQL real-time sync
|
||||
*
|
||||
|
|
@ -72,7 +74,7 @@ export function useConnectorsElectric(searchSpaceId: number | string | null) {
|
|||
|
||||
async function startSync() {
|
||||
try {
|
||||
console.log("[useConnectorsElectric] Starting sync for search space:", searchSpaceId);
|
||||
if (IS_DEV) console.log("[useConnectorsElectric] Starting sync for search space:", searchSpaceId);
|
||||
|
||||
const handle = await electricClient.syncShape({
|
||||
table: "search_source_connectors",
|
||||
|
|
@ -80,7 +82,7 @@ export function useConnectorsElectric(searchSpaceId: number | string | null) {
|
|||
primaryKey: ["id"],
|
||||
});
|
||||
|
||||
console.log("[useConnectorsElectric] Sync started:", {
|
||||
if (IS_DEV) console.log("[useConnectorsElectric] Sync started:", {
|
||||
isUpToDate: handle.isUpToDate,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue