{"action":"created","issue":{"url":"https://api.github.com/repos/nodeschool/discussions/issues/1997","repository_url":"https://api.github.com/repos/nodeschool/discussions","labels_url":"https://api.github.com/repos/nodeschool/discussions/issues/1997/labels{/name}","comments_url":"https://api.github.com/repos/nodeschool/discussions/issues/1997/comments","events_url":"https://api.github.com/repos/nodeschool/discussions/issues/1997/events","html_url":"https://github.com/nodeschool/discussions/issues/1997","id":205512832,"number":1997,"title":"SENECA IN PRACTICE - Plugin - Exercise 3 of 12","user":{"login":"sdurighello","id":8017067,"avatar_url":"https://avatars.githubusercontent.com/u/8017067?v=3","gravatar_id":"","url":"https://api.github.com/users/sdurighello","html_url":"https://github.com/sdurighello","followers_url":"https://api.github.com/users/sdurighello/followers","following_url":"https://api.github.com/users/sdurighello/following{/other_user}","gists_url":"https://api.github.com/users/sdurighello/gists{/gist_id}","starred_url":"https://api.github.com/users/sdurighello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdurighello/subscriptions","organizations_url":"https://api.github.com/users/sdurighello/orgs","repos_url":"https://api.github.com/users/sdurighello/repos","events_url":"https://api.github.com/users/sdurighello/events{/privacy}","received_events_url":"https://api.github.com/users/sdurighello/received_events","type":"User","site_admin":false},"labels":[{"id":533095336,"url":"https://api.github.com/repos/nodeschool/discussions/labels/seneca-in-practice","name":"seneca-in-practice","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-02-06T08:13:54Z","updated_at":"2017-02-21T16:31:24Z","closed_at":null,"body":"* node version: v7.2.0\r\n* npm version:  3.10.9\r\n* os: mac\r\n\r\n### Error output\r\n```\r\nCalling plugin with left: 90, right: 54\r\n{\"kind\":\"notice\",\"notice\":\"hello seneca gmftpp1zwx6g/1486153915040/12088/3.2.2/-\",\"level\":\"info\",\"when\":1486153915064}\r\n{\"kind\":\"notice\",\"notice\":\"hello seneca nmjdtqidbktf/1486153915306/12088/3.2.2/-\",\"level\":\"info\",\"when\":1486153915361}\r\n[]\r\n{\"notice\":\"seneca: closed\",\"code\":\"closed\",\"err\":{\"eraro\":true,\"orig\":null,\"code\":\"closed\",\"seneca\":true,\"package\":\"seneca\",\"msg\":\"seneca: closed\",\"details\":{\"args\":\"{ role: 'math', cmd: 'sum', left: 90, right: 54 }\",\"plugin\":{}},\"callpoint\":\"at handle_inward_break (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:1155:23)\"},\"msg\":{\"role\":\"math\",\"cmd\":\"sum\",\"left\":90,\"right\":54,\"meta$\":{}},\"meta\":{},\"listen\":false,\"transport\":{},\"kind\":\"act\",\"case\":\"ERR\",\"duration\":1,\"level\":\"error\",\"when\":1486153915492}\r\n{ Error: seneca: closed\r\n    at Object.errormaker [as error] (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/eraro/eraro.js:94:15)\r\n    at handle_inward_break (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:1155:23)\r\n    at execute_action (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:1050:11)\r\n    at Object.act_fn [as fn] (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:1013:11)\r\n    at Immediate.processor (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/gate-executor/gate-executor.js:136:14)\r\n    at runCallback (timers.js:649:20)\r\n    at tryOnImmediate (timers.js:622:5)\r\n    at processImmediate [as _immediateCallback] (timers.js:594:5)\r\n  eraro: true,\r\n  orig: null,\r\n  code: 'closed',\r\n  seneca: true,\r\n  package: 'seneca',\r\n  msg: 'seneca: closed',\r\n  details: \r\n   { args: '{ role: \\'math\\', cmd: \\'sum\\', left: 90, right: 54 }',\r\n     plugin: {} },\r\n  callpoint: 'at handle_inward_break (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:1155:23)' }\r\n\r\n\r\nSeneca Fatal Error\r\n==================\r\n\r\nMessage: seneca: use-plugin: No name property found for plugin defined by Object {}.\r\n\r\nCode: plugin_no_name\r\n\r\nDetails: { 'orig$': \r\n   { Error: use-plugin: No name property found for plugin defined by Object {}.\r\n       at errormaker (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/eraro/eraro.js:94:15)\r\n       at build_plugindesc (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/use-plugin/use.js:148:46)\r\n       at Object.use (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/use-plugin/use.js:78:22)\r\n       at Seneca.api_use [as use] (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/node_modules/seneca/seneca.js:954:29)\r\n       at Object.<anonymous> (/Users/sdurighello/.nvm/versions/node/v7.2.0/lib/node_modules/seneca-in-practice/problems/plugin/seneca-plugin-executor.js:18:8)\r\n       at Module._compile (module.js:571:32)\r\n       at Object.Module._extensions..js (module.js:580:10)\r\n // copy your error output here\r\n```\r\n\r\n### My Code\r\n```js\r\n // operations.js\r\nmodule.exports = function plugin(options) {\r\n\r\n    this.add({role: 'math', cmd: 'sum'}, (msg, respond) => {\r\n        const sum = msg.left + msg.right;\r\n        respond(null, {answer: sum});\r\n    });\r\n\r\n    return 'operations'\r\n};\r\n\r\n// client.js\r\nconst seneca = require('seneca')();\r\nconst operations = require('./operations');\r\n\r\nconst left = parseInt(process.argv[2]);\r\nconst right = parseInt(process.argv[3]);\r\n\r\nseneca.use('./operations', {});\r\n\r\nseneca.ready(function (err) {\r\n    if(err) return console.error(err);\r\n    seneca.act({role: 'math', cmd: 'sum', left: left, right: right}, console.log)\r\n});\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nodeschool/discussions/issues/comments/281397226","html_url":"https://github.com/nodeschool/discussions/issues/1997#issuecomment-281397226","issue_url":"https://api.github.com/repos/nodeschool/discussions/issues/1997","id":281397226,"user":{"login":"laur3d","id":1803831,"avatar_url":"https://avatars.githubusercontent.com/u/1803831?v=3","gravatar_id":"","url":"https://api.github.com/users/laur3d","html_url":"https://github.com/laur3d","followers_url":"https://api.github.com/users/laur3d/followers","following_url":"https://api.github.com/users/laur3d/following{/other_user}","gists_url":"https://api.github.com/users/laur3d/gists{/gist_id}","starred_url":"https://api.github.com/users/laur3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laur3d/subscriptions","organizations_url":"https://api.github.com/users/laur3d/orgs","repos_url":"https://api.github.com/users/laur3d/repos","events_url":"https://api.github.com/users/laur3d/events{/privacy}","received_events_url":"https://api.github.com/users/laur3d/received_events","type":"User","site_admin":false},"created_at":"2017-02-21T16:31:24Z","updated_at":"2017-02-21T16:31:24Z","body":"Having exaclty the same problem\r\nworks with node index.js 1 3\r\n`\r\n// index.js\r\nconst seneca = require('seneca')();\r\n\r\nconst left = Number(process.argv[2]);\r\nconst right = Number(process.argv[3]);\r\n\r\nseneca.use('./operations', {});\r\n\r\nseneca.ready(function (err) {\r\n    if(err) return console.error(err);\r\n    \r\n    console.log(seneca.hasplugin('operations'));\r\n    \r\n    seneca.act({role: 'math', cmd: 'sum', left: left, right: right}, (err, response) => {\r\n        if(err) console.error(err);\r\n        console.log(response); \r\n    });\r\n});\r\n\r\n//operations.js\r\n\r\n'use strict'\r\n\r\nmodule.exports = function (options) {\r\n    \r\n    this.add({role: 'math', cmd:'sum'}, function(msg, next){\r\n       next(null, {answer: (msg.left + msg.right)});\r\n    });\r\n    \r\n    return 'operations';\r\n}\r\n\r\n// console\r\n(node:7440) DeprecationWarning: 'root' is deprecated, use 'global'\r\n{\"kind\":\"notice\",\"notice\":\"hello seneca 2w00hm4m3ijo/1487694626984/7440/3.3.0/-\",\"level\":\"info\",\"when\":1487694627216}\r\ntrue\r\n{ answer: 4 }\r\n\r\n`\r\n\r\nbut getting the same crash if i try with the seneca- command ... "}}
{"actor":{"display_login":"laur3d"}}