BabylonJS/Babylon.js · error · Error

Cannot connect two points of type ${this.connectionType}

Error message

Cannot connect two points of type ${this.connectionType}

What it means

Thrown by FlowGraphConnectionPoint.connectTo when both points have the same connection type (e.g. both are inputs or both are outputs). A flow-graph connection must link a point of one direction to a point of the opposite direction, so same-type connections are rejected before any state is mutated.

Source

Thrown at packages/dev/core/src/FlowGraph/flowGraphConnection.ts:105

    public _isSingularConnection(): boolean {
        return true;
    }

    /**
     * Returns if a point is connected to any other point.
     * @returns boolean indicating if the point is connected.
     */
    public isConnected(): boolean {
        return this._connectedPoint.length > 0;
    }

    /**
     * Connects two connections together.
     * @param point the connection to connect to.
     */
    public connectTo(point: ConnectedToT): void {
        if (this._connectionType === point._connectionType) {
            throw new Error(`Cannot connect two points of type ${this.connectionType}`);
        }
        if ((this._isSingularConnection() && this._connectedPoint.length > 0) || (point._isSingularConnection() && point._connectedPoint.length > 0)) {
            throw new Error("Max number of connections for point reached");
        }
        this._connectedPoint.push(point);
        point._connectedPoint.push(this);
    }

    /**
     * Disconnects two connections.
     * @param point the connection to disconnect from.
     * @param removeFromLocal if true, the connection will be removed from the local connection list.
     */
    public disconnectFrom(point: ConnectedToT, removeFromLocal = true): void {
        const indexLocal = this._connectedPoint.indexOf(point);
        const indexConnected = point._connectedPoint.indexOf(this);
        if (indexLocal === -1 || indexConnected === -1) {
            return;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Check connectionType (input/output) of both points before connecting and connect opposite directions
  2. Use the block's dataInputs/dataOutputs/signalInputs/signalOutputs accessors to pick the correct counterpart point
  3. Log both points' connectionType when debugging to confirm directions

Example fix

// before
blockA.dataOutputs[0].connectTo(blockB.dataOutputs[0]);
// after
blockA.dataOutputs[0].connectTo(blockB.dataInputs[0]);
Defensive patterns

Strategy: validation

Validate before calling

if (a.connectionType === b.connectionType) {
  throw new Error(`Refusing to connect two ${a.connectionType} points`);
}
a.connectTo(b);

Type guard

function canConnect(a: FlowGraphConnectionPoint, b: FlowGraphConnectionPoint): boolean {
  return a.connectionType !== b.connectionType;
}

Prevention

When it happens

Trigger: Calling connectTo() on two FlowGraphConnectionPoints where this._connectionType === point._connectionType, e.g. dataOut.connectTo(otherDataOut) or input.connectTo(otherInput).

Common situations: Building graphs programmatically and accidentally wiring an output to an output; misreading the connectTo API as 'attach to any point'; refactoring code where the direction of a point variable changed.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/d302208899f1438f. Report an issue: GitHub.