Prune console.log() (#5867)

Introduce a no-console rule in ESLint configuration and remove existing
console log statements throughout the codebase, replacing some with
warnings or comments.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5867-Prune-console-log-27e6d73d365081bcbad8c36cfb5b258c)
by [Unito](https://www.unito.io)
This commit is contained in:
Johnpaul Chiwetelu
2025-10-02 02:34:58 +01:00
committed by GitHub
parent 20731fe3f0
commit 01b3aeae68
28 changed files with 61 additions and 140 deletions

View File

@@ -274,8 +274,6 @@ export class LGraph
* @param o data from previous serialization [optional]
*/
constructor(o?: ISerialisedGraph | SerialisableGraph) {
if (LiteGraph.debug) console.log('Graph created')
/** @see MapProxyHandler */
const links = this._links
MapProxyHandler.bindAllMethods(links)
@@ -532,7 +530,7 @@ export class LGraph
this.errors_in_execution = true
if (LiteGraph.throw_errors) throw error
if (LiteGraph.debug) console.log('Error during execution:', error)
if (LiteGraph.debug) console.error('Error during execution:', error)
this.stop()
}
}
@@ -1167,7 +1165,7 @@ export class LGraph
const ctor = LiteGraph.registered_node_types[node.type]
if (node.constructor == ctor) continue
console.log('node being replaced by newer version:', node.type)
console.warn('node being replaced by newer version:', node.type)
const newnode = LiteGraph.createNode(node.type)
if (!newnode) continue
_nodes[i] = newnode
@@ -1229,9 +1227,6 @@ export class LGraph
/* Called when something visually changed (not the graph!) */
change(): void {
if (LiteGraph.debug) {
console.log('Graph changed')
}
this.canvasAction((c) => c.setDirty(true, true))
this.on_change?.(this)
}
@@ -1626,12 +1621,6 @@ export class LGraph
} else {
throw new TypeError('Subgraph input node is not a SubgraphInput')
}
console.debug(
'Reconnect input links in parent graph',
{ ...link },
this.links.get(link.id),
this.links.get(link.id) === link
)
for (const resolved of others) {
resolved.link.disconnect(this)
@@ -2233,7 +2222,7 @@ export class LGraph
let node = LiteGraph.createNode(String(n_info.type), n_info.title)
if (!node) {
if (LiteGraph.debug)
console.log('Node not found or has errors:', n_info.type)
console.warn('Node not found or has errors:', n_info.type)
// in case of error we create a replacement node to avoid losing info
node = new LGraphNode('')

View File

@@ -6406,7 +6406,7 @@ export class LGraphCanvas
return true
}
console.log(`failed creating ${nodeNewType}`)
console.error(`failed creating ${nodeNewType}`)
}
}
return false

View File

@@ -1950,7 +1950,7 @@ export class LGraphNode
try {
this.removeWidget(widget)
} catch (error) {
console.debug('Failed to remove widget', error)
console.error('Failed to remove widget', error)
}
}
@@ -2583,12 +2583,7 @@ export class LGraphNode
if (slotIndex !== undefined)
return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId)
console.debug(
'[connectByType]: no way to connect type:',
target_slotType,
'to node:',
target_node
)
// No compatible slot found - connection not possible
return null
}
@@ -2621,7 +2616,7 @@ export class LGraphNode
if (slotIndex !== undefined)
return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId)
console.debug(
console.error(
'[connectByType]: no way to connect type:',
source_slotType,
'to node:',
@@ -2661,7 +2656,7 @@ export class LGraphNode
if (!graph) {
// could be connected before adding it to a graph
// due to link ids being associated with graphs
console.log(
console.error(
"Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."
)
return null
@@ -2672,11 +2667,12 @@ export class LGraphNode
slot = this.findOutputSlot(slot)
if (slot == -1) {
if (LiteGraph.debug)
console.log(`Connect: Error, no slot of name ${slot}`)
console.error(`Connect: Error, no slot of name ${slot}`)
return null
}
} else if (!outputs || slot >= outputs.length) {
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
if (LiteGraph.debug)
console.error('Connect: Error, slot number not found')
return null
}
@@ -2696,7 +2692,7 @@ export class LGraphNode
targetIndex = target_node.findInputSlot(target_slot)
if (targetIndex == -1) {
if (LiteGraph.debug)
console.log(`Connect: Error, no slot of name ${targetIndex}`)
console.error(`Connect: Error, no slot of name ${targetIndex}`)
return null
}
} else if (target_slot === LiteGraph.EVENT) {
@@ -2728,7 +2724,8 @@ export class LGraphNode
!target_node.inputs ||
targetIndex >= target_node.inputs.length
) {
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
if (LiteGraph.debug)
console.error('Connect: Error, slot number not found')
return null
}
@@ -2955,11 +2952,12 @@ export class LGraphNode
slot = this.findOutputSlot(slot)
if (slot == -1) {
if (LiteGraph.debug)
console.log(`Connect: Error, no slot of name ${slot}`)
console.error(`Connect: Error, no slot of name ${slot}`)
return false
}
} else if (!this.outputs || slot >= this.outputs.length) {
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
if (LiteGraph.debug)
console.error('Connect: Error, slot number not found')
return false
}
@@ -3075,19 +3073,19 @@ export class LGraphNode
slot = this.findInputSlot(slot)
if (slot == -1) {
if (LiteGraph.debug)
console.log(`Connect: Error, no slot of name ${slot}`)
console.error(`Connect: Error, no slot of name ${slot}`)
return false
}
} else if (!this.inputs || slot >= this.inputs.length) {
if (LiteGraph.debug) {
console.log('Connect: Error, slot number not found')
console.error('Connect: Error, slot number not found')
}
return false
}
const input = this.inputs[slot]
if (!input) {
console.debug('disconnectInput: input not found', slot, this.inputs)
console.error('disconnectInput: input not found', slot, this.inputs)
return false
}
@@ -3116,19 +3114,16 @@ export class LGraphNode
const target_node = graph.getNodeById(link_info.origin_id)
if (!target_node) {
console.debug(
'disconnectInput: target node not found',
link_info.origin_id
console.error(
'disconnectInput: output not found',
link_info.origin_slot
)
return false
}
const output = target_node.outputs[link_info.origin_slot]
if (!output?.links?.length) {
console.debug(
'disconnectInput: output not found',
link_info.origin_slot
)
// Output not found - may have been removed
return false
}

View File

@@ -398,8 +398,6 @@ export class LiteGraphGlobal {
throw 'Cannot register a simple object, it must be a class with a prototype'
base_class.type = type
if (this.debug) console.log('Node registered:', type)
const classname = base_class.name
const pos = type.lastIndexOf('/')
@@ -415,7 +413,7 @@ export class LiteGraphGlobal {
const prev = this.registered_node_types[type]
if (prev && this.debug) {
console.log('replacing node type:', type)
console.warn('replacing node type:', type)
}
this.registered_node_types[type] = base_class
@@ -524,7 +522,7 @@ export class LiteGraphGlobal {
): LGraphNode | null {
const base_class = this.registered_node_types[type]
if (!base_class) {
if (this.debug) console.log(`GraphNode type "${type}" not registered.`)
if (this.debug) console.warn(`GraphNode type "${type}" not registered.`)
return null
}
@@ -637,7 +635,6 @@ export class LiteGraphGlobal {
continue
try {
if (this.debug) console.log('Reloading:', src)
const dynamicScript = document.createElement('script')
dynamicScript.type = 'text/javascript'
dynamicScript.src = src
@@ -645,11 +642,9 @@ export class LiteGraphGlobal {
script_file.remove()
} catch (error) {
if (this.throw_errors) throw error
if (this.debug) console.log('Error while reloading', src)
if (this.debug) console.error('Error while reloading', src)
}
}
if (this.debug) console.log('Nodes reloaded')
}
// separated just to improve if it doesn't work
@@ -749,7 +744,7 @@ export class LiteGraphGlobal {
// convert pointerevents to touch event when not available
if (sMethod == 'pointer' && !window.PointerEvent) {
console.warn("sMethod=='pointer' && !window.PointerEvent")
console.log(
console.warn(
`Converting pointer[${sEvent}] : down move up cancel enter TO touchstart touchmove touchend, etc ..`
)
switch (sEvent) {
@@ -774,7 +769,7 @@ export class LiteGraphGlobal {
break
}
case 'enter': {
console.log('debug: Should I send a move event?') // ???
// TODO: Determine if a move event should be sent
break
}
// case "over": case "out": not used at now

View File

@@ -906,7 +906,6 @@ export class LinkConnector {
if (connectingTo === 'output') {
// Dropping new output link
const output = node.findOutputByType(firstLink.fromSlot.type)?.slot
console.debug('out', node, output, firstLink.fromSlot)
if (output === undefined) {
console.warn(
`Could not find slot for link type: [${firstLink.fromSlot.type}].`
@@ -918,7 +917,6 @@ export class LinkConnector {
} else if (connectingTo === 'input') {
// Dropping new input link
const input = node.findInputByType(firstLink.fromSlot.type)?.slot
console.debug('in', node, input, firstLink.fromSlot)
if (input === undefined) {
console.warn(
`Could not find slot for link type: [${firstLink.fromSlot.type}].`

View File

@@ -271,9 +271,9 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode {
// Bypass nodes by finding first input with matching type
const matchingIndex = this.#getBypassSlotIndex(slot, type)
// No input types match
// No input types match - bypass not possible
if (matchingIndex === -1) {
console.debug(
console.warn(
`[ExecutableNodeDTO.resolveOutput] No input types match type [${type}] for id [${this.id}] slot [${slot}]`,
this
)

View File

@@ -175,8 +175,6 @@ export class SubgraphInput extends SubgraphSlot {
}
widgets.push(widget)
} else {
console.debug('No input found on link id', linkId, link)
}
}
return widgets

View File

@@ -188,7 +188,7 @@ export class SubgraphInputNode
const subgraphInput = this.slots.at(subgraphInputIndex)
if (!subgraphInput) {
console.debug(
console.warn(
'disconnectNodeInput: subgraphInput not found',
this,
subgraphInputIndex
@@ -201,7 +201,7 @@ export class SubgraphInputNode
if (index !== -1) {
subgraphInput.linkIds.splice(index, 1)
} else {
console.debug(
console.warn(
'disconnectNodeInput: link ID not found in subgraphInput linkIds',
link.id
)

View File

@@ -430,7 +430,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
const inputSlot = this.subgraph.inputNode.slots[slot]
const innerLinks = inputSlot.getLinks()
if (innerLinks.length === 0) {
console.debug(
console.warn(
`[SubgraphNode.resolveSubgraphInputLinks] No inner links found for input slot [${slot}] ${inputSlot.name}`,
this
)
@@ -447,9 +447,10 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
resolveSubgraphOutputLink(slot: number): ResolvedConnection | undefined {
const outputSlot = this.subgraph.outputNode.slots[slot]
const innerLink = outputSlot.getLinks().at(0)
if (innerLink) return innerLink.resolve(this.subgraph)
console.debug(
if (innerLink) {
return innerLink.resolve(this.subgraph)
}
console.warn(
`[SubgraphNode.resolveSubgraphOutputLink] No inner link found for output slot [${slot}] ${outputSlot.name}`,
this
)

View File

@@ -116,7 +116,7 @@ export function getBoundaryLinks(
const resolved = LLink.resolve(input.link, graph)
if (!resolved) {
console.debug(`Failed to resolve link ID [${input.link}]`)
console.warn(`Failed to resolve link ID [${input.link}]`)
continue
}

View File

@@ -426,7 +426,6 @@ describe('ExecutableNodeDTO Integration', () => {
describe('ExecutableNodeDTO Scale Testing', () => {
it('should create DTOs at scale', () => {
const graph = new LGraph()
const startTime = performance.now()
const dtos: ExecutableNodeDTO[] = []
// Create DTOs to test performance
@@ -440,16 +439,11 @@ describe('ExecutableNodeDTO Scale Testing', () => {
dtos.push(dto)
}
const endTime = performance.now()
const duration = endTime - startTime
expect(dtos).toHaveLength(1000)
// Test deterministic properties instead of flaky timing
expect(dtos[0].id).toBe('parent:0')
expect(dtos[999].id).toBe('parent:999')
expect(dtos.every((dto, i) => dto.id === `parent:${i}`)).toBe(true)
console.log(`Created 1000 DTOs in ${duration.toFixed(2)}ms`)
})
it('should handle complex path generation correctly', () => {