Search code examples
sequelize.jsfeathersjsfeathers-sequelize

feathers-sequelize does not work with ```raw: false``` anymore after upgrading to Buzzard


I am using feathersjs (with websockets) and sequelize on my server and upgraded to Buzzard version. This hook is on my server and used to work fine before upgrading: ```

module.exports = function (options = {}) { 
  return function (hook) {
    if (hook.params.query && hook.params.query.include) {
      const joinModel = hook.app.service('favorites_points').Model;
      const pointsModel = hook.app.service('points').Model;
      hook.params.sequelize = {
        raw: false,
        include: [{
          model: joinModel,
          as: 'FavPoints',
          include: [{
            model: pointsModel
          }]
        }]
      };
      delete hook.params.query.include;
    }
    return Promise.resolve(hook);
  };
};

After upgrading, when called from client with: api.service('users').get(2, {query: {include: true}})

I get this error (btw: when I leave out the inner include: [{ model: pointsModel }], same error remains):

index.js?3d97:235 Uncaught (in promise) Error: Maximum call stack size exceeded
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:28:20)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:35:11)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
convert @ index.js?3d97:235
(anonymous) @ client.js?8dbe:71
Socket.onack @ socket.js?0183:312
Socket.onpacket @ socket.js?0183:236
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Manager.ondecoded @ manager.js?0ad8:332
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Decoder.add @ index.js?5f3d:241
Manager.ondata @ manager.js?0ad8:322
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Socket.onPacket @ socket.js?5eac:456
(anonymous) @ socket.js?5eac:273
Emitter.emit @ index.js?a675:133
Transport.onPacket @ transport.js?64e8:145
Transport.onData @ transport.js?64e8:137
ws.onmessage @ websocket.js?7304:147
Promise rejected (async)
queryMe @ Nearby.vue?9ccf:48
boundFn @ vue.runtime.esm.js?ff9b:189
click @ Nearby.vue?dc3e:39
invoker @ vue.runtime.esm.js?ff9b:1979
Vue.$emit @ vue.runtime.esm.js?ff9b:2489
click @ quasar.esm.js?8bfb:3118
boundFn @ vue.runtime.esm.js?ff9b:188
invoker @ vue.runtime.esm.js?ff9b:1979
fn._withTask.fn._withTask @ vue.runtime.esm.js?ff9b:1777

When I comment out raw: false, it gives proper output. I checked, but in my 'before upgrade version' the query also works when I leave raw: false, out, however the output-structure is different (more nested) when its added, so makes me think that sequelize is simply circumvented and probably there is no eager-loading etc. So I would like the use raw: false,

After upgrade Package.json for the server:

"@feathersjs/authentication": "^2.1.0",
"@feathersjs/authentication-jwt": "^1.0.1",
"@feathersjs/authentication-local": "^1.0.2",
"@feathersjs/authentication-oauth2": "^1.0.2",
"@feathersjs/configuration": "^1.0.1",
"@feathersjs/errors": "^3.2.0",
"@feathersjs/express": "^1.1.2",
"@feathersjs/feathers": "https://github.com/feathersjs/feathers.git#master",
"@feathersjs/socketio": "^3.0.1",
"feathers-authentication-hooks": "^0.1.5",
"feathers-hooks-common": "git://github.com/feathers-plus/feathers-hooks-common.git#master",
"feathers-sequelize": "^3.0.0",
"sequelize": "^4.28.6",

Before upgrade Package.json on the server:

"feathers": "^2.2.3",
"feathers-authentication": "^1.3.0",
"feathers-authentication-hooks": "^0.1.5",
"feathers-authentication-jwt": "^0.3.2",
"feathers-authentication-local": "^0.4.4",
"feathers-authentication-oauth2": "^0.3.2",
"feathers-blob": "^1.3.1",
"feathers-configuration": "^0.4.2",
"feathers-errors": "^2.9.2",
"feathers-hooks": "^2.1.2",
"feathers-hooks-common": "^3.10.0",
"feathers-rest": "^1.8.1",
"feathers-seeder": "^1.0.10",
"feathers-sequelize": "^2.4.0",
"feathers-socketio": "^2.0.1",
"sequelize": "^4.23.1",

My question: why does it not work anymore with raw: false, and how can I solve this?


Solution

  • After adding a dehydrate hook (as an after hook) the output is as expected. It's not clear to me why before upgrading this was not an issue.