Target and source elements are null in a "connect.end" listener

I added this listener to my bpmn modeler

eventBus.on('connect.end',2000, function(event) {
      let context=event.context;
      if ( || !self.checkConnection(context)){
        return false;

So when this listener is triggered(when I create a connection) I print the context in the console assuming I would find both the ids of the source shape and the target shape but as you can see in the image below the target information is missing/null.

  • Is it supposed to be this way? if so is there is any alternative (another listener I could use,I already tried a bunch of listeners but this one was the closest to what I was looking for apart from this issue)?.

codesandbox here.


Edit: I just realized that source is also null, but I am able to find the source Id with context.start but can’t figure out how to get the target id still.

I’d avoid using connect.end since, it won’t cover all connection creations, especially not those using the connection.create command. Instead, use the commandStack.connection.create.postExecute event.

eventBus.on('commandStack.connection.create.postExecuted', function (event) {
  const context = event.context;

  const source = context.source;

  const target =;

  console.log("Source:", source);

  console.log("Target:", target);

Source: Sandbox

1 Like

Thank you for your reply, I already tried commandStack.connection.create.postExecute though, the issue was that I couldn’t cancel/not allow the connection based on a condition (which is what I’m looking for) by returning false for example like other custom rules I used.

updated sandbox