Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seneca.act callback limited to two arguments #340

Closed
chesles opened this issue Feb 14, 2016 · 2 comments
Closed

seneca.act callback limited to two arguments #340

chesles opened this issue Feb 14, 2016 · 2 comments
Assignees
Milestone

Comments

@chesles
Copy link
Contributor

chesles commented Feb 14, 2016

I came across this while using seneca-postgres-store's native method. The callback to native expects 3 arguments: err, client and a done callback that is used to release the client back to the connection pool. When using the native method, the 3rd argument is not passed back, so there's no way to release the client when finished.

I traced the problem to where the callback gets called in seneca.js:

actdone.apply(delegate, result.slice(0, 2)) // note: err == result[0]

I can't think of any problems that might arise from allowing 3+ arguments here; was there a good reason for slicing off the rest of the arguments? It looks like before 9397de6 seneca just passed everything along.

@chesles
Copy link
Contributor Author

chesles commented Feb 14, 2016

A simple example to demonstrate this:

seneca.add({ role: 'sample', cmd: 'arity-test' }, function (args, done) {
  return done.apply(null, args.items)
})

var items =  [ null, { one: 1 }, { two: 2 }, { three: 3 }] 
seneca.act({ role: 'sample', cmd: 'arity-test', items: items}, function () {
  console.log('Got %s arguments', arguments.length)
  // Got 2 arguments
})

@rjrodger
Copy link
Collaborator

sorry - this is by design - the response is ideally a JSON object containing everything you want to send back

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants