rgthree-comfy icon indicating copy to clipboard operation
rgthree-comfy copied to clipboard

issues with rgthree-comfy/reroute.js

Open Fr-Otaku opened this issue 8 months ago • 4 comments

Hello guys, As the screenshot shows, there is a problem, or rather several, with one of your scripts. To be able to load a workflow and install the missing nodes, I must first disable rgthree, install the repos, and then re-enable rgthree. Can you verify what's happening with this script? Thanks in advance and especially thank you for your work.

Image

Fr-Otaku avatar Apr 07 '25 20:04 Fr-Otaku

Looking at the error I think this is a duplicate of https://github.com/rgthree/rgthree-comfy/issues/453 which was a bug in ComfyUI filed here: https://github.com/Comfy-Org/ComfyUI_frontend/issues/3248

I think the fix has made it's way to ComfyUI main, tough. Have you updated your ComfyUI and it's Frontend recently?

rgthree avatar Apr 19 '25 01:04 rgthree

hey sorry i seem to have created an issue duplicate: https://github.com/rgthree/rgthree-comfy/issues/484#issue-3034593281 ig it didn't come up in my search because your error was in screenshot form.

anyway i made this edit it in "reroute.js" file:

}
onConnectionsChange(type, _slotIndex, connected, _link_info, _ioSlot) {
    if (connected && type === LiteGraph.OUTPUT) {
        const types = new Set(
            this.outputs[0].links
                .map((l) => app.graph.links[l]) // Get the link object first
                .filter((link) => link) // Ensure the link object exists
                .map((link) => link.type) // Now get the type
                .filter((t) => t !== "*"),
        );
        if (types.size > 1) {
            const linksToDisconnect = [];
            // Iterate backwards when removing items to avoid index issues
            for (let i = this.outputs[0].links.length - 2; i >= 0; i--) {
                const linkId = this.outputs[0].links[i];
                const link = app.graph.links[linkId];
                // Add an extra check here too, just in case.
                if (link) {
                    linksToDisconnect.push(link);
                }
            }
            for (const link of linksToDisconnect) {
                const node = app.graph.getNodeById(link.target_id);
                node.disconnectInput(link.target_slot);
            }
        }
    }
    this.scheduleStabilize();
}

that seems to have fixed it but no idea if this (vibe)code is any good

tazztone avatar May 03 '25 08:05 tazztone

hey sorry i seem to have created an issue duplicate: #484 (comment) ig it didn't come up in my search because your error was in screenshot form.

anyway i made this edit it in "reroute.js" file:

}
onConnectionsChange(type, _slotIndex, connected, _link_info, _ioSlot) {
    if (connected && type === LiteGraph.OUTPUT) {
        const types = new Set(
            this.outputs[0].links
                .map((l) => app.graph.links[l]) // Get the link object first
                .filter((link) => link) // Ensure the link object exists
                .map((link) => link.type) // Now get the type
                .filter((t) => t !== "*"),
        );
        if (types.size > 1) {
            const linksToDisconnect = [];
            // Iterate backwards when removing items to avoid index issues
            for (let i = this.outputs[0].links.length - 2; i >= 0; i--) {
                const linkId = this.outputs[0].links[i];
                const link = app.graph.links[linkId];
                // Add an extra check here too, just in case.
                if (link) {
                    linksToDisconnect.push(link);
                }
            }
            for (const link of linksToDisconnect) {
                const node = app.graph.getNodeById(link.target_id);
                node.disconnectInput(link.target_slot);
            }
        }
    }
    this.scheduleStabilize();
}

that seems to have fixed it but no idea if this (vibe)code is any good

@tazztone try to update your ComfyUI Frontend (it needs to be manually updated, its different from updating ComfyUi itself) instead of changing the custom node code. It should be fixed. IDK, you should try it. I don't have this error on the current version.

diodiogod avatar May 06 '25 17:05 diodiogod

Is this still happening for anyone on the latest Cupdated ComfyUI? There was a bug in ComfyUI_frontend that had its fix in late march which times well to the original filing here. See https://github.com/Comfy-Org/ComfyUI_frontend/issues/3248

rgthree avatar May 07 '25 11:05 rgthree