 onRuntimeComponent = null
 
 subscribe = (runtime, port) ->
-  onRuntimeConnected = ->
+  requestListing = ->
+    return unless runtime.canDo 'protocol:component'
     runtime.sendComponent 'list'
     port.connect()
+
+  onRuntimeConnected = -> do requestListing
   onRuntimeComponent = (message) ->
     return unless message.command is 'component'
     return if message.payload.name in ['Graph', 'ReadDocument']

    process: (event, payload) ->
      return unless event is 'data'
      unsubscribe c.runtime, c.outPorts.out if c.runtime
      unless payload.canDo 'protocol:component'
        return c.error new Error "Runtime #{payload.definition.id} is not able to list components"
      c.runtime = payload
      subscribe c.runtime, c.outPorts.out

    port.send
      componentDefinition: definition

  runtime.on 'capabilities', onRuntimeConnected
  runtime.on 'component', onRuntimeComponent
  do requestListing if runtime.isConnected()

unsubscribe = (runtime, port) ->
  port.disconnect()
