Skip to content

Commit 379a91d

Browse files
committed
fix
1 parent 4613190 commit 379a91d

File tree

3 files changed

+5
-42
lines changed

3 files changed

+5
-42
lines changed

examples/react/todo/src/lib/collections.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { api } from "./api"
1212
const queryClient = new QueryClient()
1313

1414
// Initialize DB devtools early (idempotent - safe to call multiple times)
15-
console.log('🏗️ Collections.ts: Initializing devtools before creating collections...')
1615
initializeDbDevtools()
1716

1817
// Electric Todo Collection

packages/react-db-devtools/src/ReactDbDevtools.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,33 @@ export function TanStackReactDbDevtools(props: TanStackReactDbDevtoolsProps = {}
1313
const [devtools, setDevtools] = useState<TanstackDbDevtools | null>(null)
1414
const initializingRef = useRef(false)
1515

16-
console.log('ReactDbDevtools: Component rendered with props:', props)
17-
1816
// Initialize devtools only on client side
1917
useEffect(() => {
20-
console.log('ReactDbDevtools: useEffect triggered')
21-
console.log('ReactDbDevtools: window exists:', typeof window !== 'undefined')
22-
console.log('ReactDbDevtools: ref.current exists:', !!ref.current)
23-
console.log('ReactDbDevtools: already initializing:', initializingRef.current)
24-
2518
if (typeof window === 'undefined' || !ref.current || initializingRef.current) {
26-
console.log('ReactDbDevtools: Early return - no window, ref, or already initializing')
2719
return
2820
}
2921

3022
// Set flag to prevent multiple initializations
3123
initializingRef.current = true
3224

33-
// Note: Devtools registry is now initialized in collections.ts before collections are created
34-
console.log('ReactDbDevtools: Calling initializeDbDevtools as backup (also called in collections.ts)')
35-
initializeDbDevtools()
36-
37-
console.log('ReactDbDevtools: Creating TanstackDbDevtools instance')
25+
// Note: Devtools registry is now initialized in collections.ts before collections are created
26+
initializeDbDevtools()
3827
const devtoolsInstance = new TanstackDbDevtools(props)
3928

4029
try {
41-
console.log('ReactDbDevtools: Attempting to mount devtools')
4230
// Mount the devtools to the DOM element
4331
devtoolsInstance.mount(ref.current)
44-
console.log('ReactDbDevtools: Devtools mounted successfully')
4532
setDevtools(devtoolsInstance)
4633
} catch (error) {
4734
console.error('ReactDbDevtools: Failed to mount DB devtools:', error)
4835
initializingRef.current = false // Reset flag on error
4936
}
5037

5138
return () => {
52-
console.log('ReactDbDevtools: Cleanup - unmounting devtools')
5339
try {
5440
// Only unmount if the devtools were successfully mounted
5541
if (devtoolsInstance) {
5642
devtoolsInstance.unmount()
57-
console.log('ReactDbDevtools: Devtools unmounted successfully')
5843
}
5944
} catch (error) {
6045
// Ignore unmount errors if devtools weren't mounted

packages/react-db-devtools/src/index.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,20 @@ export function initializeDbDevtools(): void {
7171
// Create the registry directly without importing SolidJS code to avoid SSR issues
7272
try {
7373
// Import and call the core initialization asynchronously, but ensure registry exists first
74-
const registryPromise = import('@tanstack/db-devtools').then((module) => {
75-
console.log('DbDevtools: Core devtools module loaded')
74+
import('@tanstack/db-devtools').then((module) => {
7675
module.initializeDbDevtools()
77-
console.log('DbDevtools: Core initialization complete')
7876
}).catch((error) => {
7977
console.warn('DbDevtools: Failed to load core devtools module:', error)
8078
})
8179

8280
// Create immediate registry that works with the SolidJS UI while core loads
8381
if (!(window as any).__TANSTACK_DB_DEVTOOLS__) {
84-
console.log('DbDevtools: Creating immediate registry...')
8582

8683
const collections = new Map()
8784

8885
const registry = {
8986
collections,
9087
registerCollection: (collection: any) => {
91-
console.log('DbDevtools: Registering collection:', collection.id)
92-
9388
const metadata = {
9489
id: collection.id,
9590
type: collection.id.startsWith('live-query-') ? 'live-query' : 'collection',
@@ -112,8 +107,6 @@ export function initializeDbDevtools(): void {
112107
}
113108

114109
collections.set(collection.id, entry)
115-
console.log('DbDevtools: Collection registered successfully:', collection.id)
116-
console.log('DbDevtools: Total collections now:', collections.size)
117110
},
118111
unregisterCollection: (id: string) => {
119112
collections.delete(id)
@@ -135,10 +128,8 @@ export function initializeDbDevtools(): void {
135128
return { ...entry.metadata }
136129
},
137130
getAllCollectionMetadata: () => {
138-
console.log('DbDevtools: getAllCollectionMetadata called, total collections:', collections.size)
139-
140131
const results = []
141-
for (const [id, entry] of collections) {
132+
for (const [, entry] of collections) {
142133
const collection = entry.weakRef.deref()
143134
if (collection) {
144135
// Collection is still alive, update metadata
@@ -148,22 +139,14 @@ export function initializeDbDevtools(): void {
148139
entry.metadata.transactionCount = collection.transactions?.size || 0
149140
entry.metadata.lastUpdated = new Date()
150141
results.push({ ...entry.metadata })
151-
console.log('DbDevtools: Found live collection:', {
152-
id,
153-
status: collection.status,
154-
size: collection.size,
155-
type: entry.metadata.type
156-
})
157142
} else {
158143
// Collection was garbage collected
159144
entry.metadata.status = 'cleaned-up'
160145
entry.metadata.lastUpdated = new Date()
161146
results.push({ ...entry.metadata })
162-
console.log('DbDevtools: Found GC\'d collection:', id)
163147
}
164148
}
165149

166-
console.log('DbDevtools: Returning metadata for', results.length, 'collections')
167150
return results
168151
},
169152
getCollection: (id: string) => {
@@ -209,7 +192,6 @@ export function initializeDbDevtools(): void {
209192

210193
// Set up the registry on window
211194
;(window as any).__TANSTACK_DB_DEVTOOLS__ = registry
212-
console.log('DbDevtools: Registry created successfully')
213195
}
214196

215197
// Set up automatic collection registration
@@ -221,16 +203,13 @@ export function initializeDbDevtools(): void {
221203
}
222204
}
223205
}
224-
225-
console.log('DbDevtools: Initialization complete')
226206
} catch (error) {
227207
console.warn('DbDevtools: Failed to initialize devtools:', error)
228208

229209
// Final fallback: set up a basic registration function so collections don't fail
230210
if (!(window as any).__TANSTACK_DB_DEVTOOLS_REGISTER__) {
231-
console.log('DbDevtools: Setting up fallback registration function...')
232211
;(window as any).__TANSTACK_DB_DEVTOOLS_REGISTER__ = (collection: any) => {
233-
console.log('DbDevtools: Fallback - collection registered:', collection.id)
212+
// Silent fallback registration
234213
}
235214
}
236215
}

0 commit comments

Comments
 (0)