senecajs / seneca-transport

Seneca micro-services message transport over TCP and HTTP.
MIT License
63 stars 45 forks source link

failed: this.act is not a function #150

Closed akileshv closed 7 years ago

akileshv commented 7 years ago

Error message

{"notice":"seneca: Action cmd:sum,integer:true,role:math failed: this.act is not a function.","code":"act_execute","err":{"eraro":true,"orig":{},"code":"act_execute","seneca":true,"package":"seneca","msg":"seneca: Action cmd:sum,integer:true,role:math failed: this.act is not a function.","details":{"message":"this.act is not a function","pattern":"cmd:sum,integer:true,role:math","instance":"Seneca/ce5syef1gppy/1486479154179/3854/3.3.0/-","orig$":{},"message$":"this.act is not a function","plugin":{}},"callpoint":"at Seneca.seneca.add (/home/akilesh/a.js:10:8)"},"actid":"1jfaw78dg6fn/itk7mdgc5xcc","msg":{"role":"math","cmd":"sum","left":1.5,"right":2.5,"integer":true,"meta$":{"mi":"1jfaw78dg6fn","tx":"itk7mdgc5xcc","id":"1jfaw78dg6fn/itk7mdgc5xcc","pattern":"cmd:sum,integer:true,role:math","action":"(o6b4hpm6q76z)","plugin_name":"root$","prior":{"chain":[],"entry":true,"depth":0},"start":1486479154289,"sync":true},"plugin$":{"name":"root$"},"tx$":"itk7mdgc5xcc"},"entry":true,"prior":[],"meta":{"raw":{"role":"math","cmd":"sum","integer":true},"plugin_name":"root$","plugin_fullname":"root$","sub":false,"client":false,"args":{"role":"math","cmd":"sum","integer":true},"rules":{},"id":"(o6b4hpm6q76z)","pattern":"cmd:sum,integer:true,role:math","msgcanon":{"cmd":"sum","integer":true,"role":"math"},"priormeta":{"raw":{"role":"math","cmd":"sum"},"plugin_name":"root$","plugin_fullname":"root$","sub":false,"client":false,"args":{"role":"math","cmd":"sum"},"rules":{},"id":"(5rezlwf8lbyq)","pattern":"cmd:sum,role:math","msgcanon":{"cmd":"sum","role":"math"},"priorpath":""},"priorpath":"(5rezlwf8lbyq);"},"client":false,"listen":false,"transport":{},"kind":"act","case":"ERR","duration":30,"level":"error","when":1486479154323}
{ TypeError: this.act is not a function
    at Seneca.seneca.add (/home/akilesh/a.js:10:8)
    at execute_action (/home/akilesh/node_modules/seneca/seneca.js:1077:20)
    at Object.act_fn [as fn] (/home/akilesh/node_modules/seneca/seneca.js:1027:11)
    at Immediate.processor (/home/akilesh/node_modules/gate-executor/gate-executor.js:136:14)
    at runCallback (timers.js:649:20)
    at tryOnImmediate (timers.js:622:5)
    at processImmediate [as _immediateCallback] (timers.js:594:5)
  eraro: true,
  orig: 
   TypeError: this.act is not a function
       at Seneca.seneca.add (/home/akilesh/a.js:10:8)
       at execute_action (/home/akilesh/node_modules/seneca/seneca.js:1077:20)
       at Object.act_fn [as fn] (/home/akilesh/node_modules/seneca/seneca.js:1027:11)
       at Immediate.processor (/home/akilesh/node_modules/gate-executor/gate-executor.js:136:14)
       at runCallback (timers.js:649:20)
       at tryOnImmediate (timers.js:622:5)
       at processImmediate [as _immediateCallback] (timers.js:594:5),
  code: 'act_execute',
  seneca: true,
  package: 'seneca',
  msg: 'seneca: Action cmd:sum,integer:true,role:math failed: this.act is not a function.',
  details: 
   { message: 'this.act is not a function',
     pattern: 'cmd:sum,integer:true,role:math',
     fn: [Function],
     cb: [Function: bound ],
     instance: 'Seneca/ce5syef1gppy/1486479154179/3854/3.3.0/-',
     'orig$': 
      TypeError: this.act is not a function
          at Seneca.seneca.add (/home/akilesh/a.js:10:8)
          at execute_action (/home/akilesh/node_modules/seneca/seneca.js:1077:20)
          at Object.act_fn [as fn] (/home/akilesh/node_modules/seneca/seneca.js:1027:11)
          at Immediate.processor (/home/akilesh/node_modules/gate-executor/gate-executor.js:136:14)
          at runCallback (timers.js:649:20)
          at tryOnImmediate (timers.js:622:5)
          at processImmediate [as _immediateCallback] (timers.js:594:5),
     'message$': 'this.act is not a function',
     plugin: {} },
  callpoint: 'at Seneca.seneca.add (/home/akilesh/a.js:10:8)' }
{"kind":"notice","notice":"hello seneca ce5syef1gppy/1486479154179/3854/3.3.0/-","level":"info","when":1486479154326}

code causes problem


seneca.add('role: math, cmd: sum',  (msg, respond) => {
  var sum = msg.left + msg.right
  respond(null, {answer: sum})
})

seneca.add('role: math, cmd: sum, integer: true', (msg, respond) => {//problem here
  // reuse role:math, cmd:sum
  this.act({
    role: 'math',
    cmd: 'sum',
    left: Math.floor(msg.left),
    right: Math.floor(msg.right)
  }, respond)
})

// this matches role:math,cmd:sum
seneca.act('role: math, cmd: sum, left: 1.5, right: 2.5',console.log)

// BUT this matches role:math,cmd:sum,integer:true
seneca.act('role: math, cmd: sum, left: 1.5, right: 2.5, integer: true', console.log)

if i change () => to function() it will work fine