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

Should socket calls require a callback? #96

Closed
marshallswain opened this issue Oct 18, 2014 · 3 comments · Fixed by #123
Closed

Should socket calls require a callback? #96

marshallswain opened this issue Oct 18, 2014 · 3 comments · Fixed by #123
Milestone

Comments

@marshallswain
Copy link
Member

This feels like a bug to me. I've been trying to do a one-off update to the server like this:

socket.emit("api/preferences::update", pref._id, pref, {});

Which results in a server crash on this error:

/Users/marshallthompson//Sites/MMA/node_modules/feathers/node_modules/rubberduck/lib/rubberduck.js:67
        throw e;
              ^
TypeError: Property 'callback' of object #<Object> is not a function
    at hookCallback (/Users/marshallthompson//Sites/MMA/node_modules/feathers-hooks/lib/before.js:39:35)
    at Object.exports.requireAuth (/Users/marshallthompson//Sites/MMA/server/hook-library.js:30:12)
    at Object.fn (/Users/marshallthompson//Sites/MMA/node_modules/feathers-hooks/lib/before.js:49:32)
    at Object.self.(anonymous function) (/Users/marshallthompson//Sites/MMA/node_modules/feathers/node_modules/uberproto/lib/proto.js:61:21)
    at hookCallback (/Users/marshallthompson//Sites/MMA/node_modules/feathers-hooks/lib/before.js:44:22)
    at Object.exports.setUserID (/Users/marshallthompson//Sites/MMA/server/hook-library.js:120:10)
    at Object.fn (/Users/marshallthompson//Sites/MMA/node_modules/feathers-hooks/lib/before.js:49:32)
    at Object.self.(anonymous function) (/Users/marshallthompson//Sites/MMA/node_modules/feathers/node_modules/uberproto/lib/proto.js:61:21)
    at Object.wrapped [as update] (/Users/marshallthompson//Sites/MMA/node_modules/feathers/node_modules/rubberduck/lib/rubberduck.js:63:12)
    at Socket.<anonymous> (/Users/marshallthompson//Sites/MMA/node_modules/feathers/lib/providers/socket/commons.js:28:23)

If I put the callback in place like this:

socket.emit('api/preferences::update', pref._id, pref, {}, function(error, data) {
    console.log(data);
});

It works as expected. That doesn't seem right to me. Do socket calls always require the callback in place?

@daffl
Copy link
Member

daffl commented Oct 18, 2014

At the moment they do although the parameters object is optional. It shouldn't be hard to make the callback optional as well. You won't be able to handle any errors though (at the least I usually add an error handler callback).

@marshallswain
Copy link
Member Author

This is fixed in #107

@lock
Copy link

lock bot commented Feb 8, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants