Skip to content

🐛 [BUG]: getHandleConnections uses outdated lookup key after v1.42.0 #1879

Open
@gasscoelho

Description

@gasscoelho

Is there an existing issue for this?

  • I have searched the existing issues and this is a new bug.

Current Behavior

The v1.42.0 introduced some changes that affected the computation of connectionLookup. In short, the useHandleConnections composable was refactored into useNodeConnections, and now uses a different lookup key strategy. But, the getHandleConnections function wasn’t updated — it still uses the old key format:

// packages/core/src/store/actions.ts
const getHandleConnections: Actions['getHandleConnections'] = ({ id, type, nodeId }) => {
  return Array.from(state.connectionLookup.get(`${nodeId}-${type}-${id ?? null}`)?.values() ?? [])
}

Here's an example of how the useNodeConnections is computing the lookup key:

// packages/core/src/composables/useNodeConnections.ts
...

const lookupKey = computed(() => {
  const currNodeId = toValue(nodeId) ?? _nodeId
  const currentHandleType = toValue(handleType)
  const currHandleId = toValue(handleId)

  let handleSuffix = ''
  if (currentHandleType) {
    handleSuffix = currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`
  }

  return `${currNodeId}${handleSuffix}`
})

...

watch(
  () => connectionLookup.value.get(lookupKey.value),

...

Because of this mismatch, getHandleConnections doesn’t return the expected results in some cases — for example, when handleId is undefined.

Expected Behavior

getHandleConnections should adopt the same key logic used in useNodeConnections.

Example (pseudo-code):

const getNodeConnections = (params: GetNodeConnectionsParams) => {
  const { nodeId, handleId, handleType } = params
  const getLookupKey = () => {
    let handleSuffix = ''
    if (handleType) {
      handleSuffix = handleId ? `-${handleType}-${handleId}` : `-${handleType}`
    }
    return `${nodeId}${handleSuffix}`
  }
  return Array.from(connectionLookup.value.get(getLookupKey())?.values() ?? [])
}

Steps To Reproduce

  1. Use version 1.42.0 or later
  2. Attempt to retrieve connections using getHandleConnections where handleId is undefined
  3. Observe missing connection data

Minimal reproduction of the issue with CodeSandbox

No response

Relevant log output


Anything else?

We might also consider renaming the function from getHandleConnections to getNodeConnections for consistency. Thoughts?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions