         throw new Error "runtime #{@definition.id} does not declare protocol:runtime"
       if definition.graph
         noflo.graph.loadFile definition.graph, (graph) =>
+          @graph = graph
+          @runtime.setMain graph
           connection.sendGraph graph, @runtime, =>
-            @runtime.setMain graph
+            # ignore
 
     # TODO: make runtime base handle ports discovery similar to capabilities?
     portsRecv = 0

    @runtime.connect()

  setupPorts: (ports) ->
    @setReady false
    if ports.inPorts.length is 0 and ports.outPorts.length is 0
      return
    # Expose remote graph's exported ports as node ports
    @prepareInport port for port in ports.inPorts
    @prepareOutport port for port in ports.outPorts
    setTimeout =>
      @setReady true
    , 100

  prepareInport: (definition) ->
    name = definition.id


    @runtime = null
    @ready = false
    @graph = null

    @inPorts = new noflo.InPorts
    @outPorts = new noflo.OutPorts
