When trying to change an existing user-record using a POST on localhost:1337/api/user/1 I get the following:
/Users/antonia/dev/projects/streama/streama-node/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:82
throw err;
^
TypeError: Expecting a function in instanceof check, but got #<bound>
at _hasBinary (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/node_modules/has-binary-data/index.js:30:41)
at hasBinary (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/node_modules/has-binary-data/index.js:56:10)
at Namespace.emit (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/lib/namespace.js:210:9)
at Object.broadcastToRoom [as broadcast] (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/sails-hook-sockets/lib/sails.sockets/broadcast-to-room.js:51:33)
at bound.broadcast (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/lib/hooks/pubsub/index.js:122:23)
at eachInstance (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/lib/hooks/pubsub/index.js:253:18)
at Function.forEach (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/lodash/dist/lodash.js:3298:15)
at bound.publish (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/lib/hooks/pubsub/index.js:250:13)
at bound [as publish] (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at bound.publishUpdate (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/lib/hooks/pubsub/index.js:708:14)
at bound [as publishUpdate] (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at updated (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/lib/hooks/blueprints/actions/update.js:71:15)
at wrapper (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:3602:19)
at applyInOriginalCtx (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:320:18)
at callback.success (/Users/antonia/dev/projects/streama/streama-node/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
Any Idea what this may be about? Saving new records works fine..
I got a similar bug with my blueprint POST and PUT routes.
I dont have any particular example, but for every models (a simple Dashboard model for exemple) created with sails generate, the sails app crashes with this message:
/Users/nunja/Documents/Node/bakabase/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:757
catch(err) { process.nextTick(function() { throw err}); }
^
TypeError: Expecting a function in instanceof check, but got dashboard,[object Object]
at _hasBinary (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/node_modules/has-binary-data/index.js:30:41)
at hasBinary (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/node_modules/has-binary-data/index.js:56:10)
at Namespace.emit (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/lib/namespace.js:210:9)
at Object.broadcastToRoom [as broadcast] (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/sails-hook-sockets/lib/sails.sockets/broadcast-to-room.js:51:33)
at bound.broadcast (/Users/nunja/Documents/Node/bakabase/node_modules/sails/lib/hooks/pubsub/index.js:122:23)
at bound.publishCreate (/Users/nunja/Documents/Node/bakabase/node_modules/sails/lib/hooks/pubsub/index.js:1192:14)
at bound [as publishCreate] (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at created (/Users/nunja/Documents/Node/bakabase/node_modules/sails/lib/hooks/blueprints/actions/create.js:43:10)
at wrapper (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:3602:19)
at applyInOriginalCtx (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:320:18)
at _normalizeCallback.callback.success (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
at _switch (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:48:28)
at /Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:242:9
at /Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
at /Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:263:32
at /Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
at bound.<anonymous> (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44)
at fn (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:60:10)
at /Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:162:20
at iterate (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:256:13)
at Object.async.forEachOfSeries.async.eachOfSeries (/Users/nunja/Documents/Node/bakabase/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:275:9)
The only workaround which works here is to override the create (or update) method in the DashboardController.
I am getting the same error, right after updating to sails 0.11.
I am also doing a PUT/POST to localhost:1337/api/user/1
Hm, very weird. Seems like possibly a bug in that particular dependency. Try reinstalling Sails to get all the latest dependencies:
npm uninstall -g sails
npm cache clean
npm install -g sails
(might need to do sudo for these)
This is because you may have a File.js model - rename it and try?!
I don't understand what you are saying @dioptre.
@dularion is this happening to you from a brand new sails 11 app? or is it from updating one? Thanks
@juanpasolano what @dularion is suggesting is that if you have a file called api/models/File.js, or some other reserved Node class, it may be causing a conflict when Sails globalizes the model. What models and services do you have in your project (in your api/models and api/services folders)?
Thanks @sgress454. That is super clear, i will do that now
UPDATE:
Its solved for me :), I did have a File model and removing it worked.
Thanks @dioptre and @sgress454
In fact the error changed to
/Users/juan/Documents/juanpa/vetapp/sites/webapp/back/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/node_modules/has-binary-data/index.js:30
(global.File && obj instanceof File)
Now all POST/PUT request are working fine :+1:
Thanks for posting, @dularion. I'm a repo bot-- nice to meet you!
It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help!
Another way by not exposing defined models as global variables with "config/globals.coffee" below.
module.exports =
globals:
models: false
services: false
I got the same error. I can confirm this issue in versions 0.11.2 , 0.12.0, 0.12.1 .
Thanks @dioptre for the fix, it worked for me.
@sgress454 I think it can be a part of the documentation as adding a model named File can be pretty common. What do you think ?
Most helpful comment
This is because you may have a File.js model - rename it and try?!