question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`raw: false,` does not work with with Buzzard

See original GitHub issue

This hook on my server:

module.exports = function (options = {}) { // eslint-disable-line no-unused-vars
  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;
    }

When called from client with (I am using websockets): api.service('users').get(2, {query: {include: true}}) Gives 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.

This hook worked fine with raw: false, before upgrading to feathers Buzzard (with matching assistance libraries). My current package.json for the server has these:

    "@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",

What is going on? Why does my query suddenly work without raw: false, ??

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
DesignByOnyxcommented, Feb 5, 2018

Just wanted to leave a comment here for some closure. By default, sequelize defaults to raw: true. This was a controversial decision, but the reason behind the decision was so that feathers-sequelize could interoperate with other hooks, especially feathers-hooks-commom. As soon as you set raw: false, feathers-sequelize should not work with common hooks.

You say that using raw: false did work before the upgrade, but if it did it was merely a fluke and you likely found an edge case where it worked. As it stands, here are the general rules with regard to feathers-sequelize.

  • For simple service calls (without associations, raw: true by default), everything should work out of the box, even with 3rd party (common) hooks.
  • When eager loading (using the include option), you should set raw: false. This will give you properly nested data (this is a shortcoming of sequelize).
  • If you ever use raw: false AND want to use 3rd party (common) hooks, you MUST deydrate() the data first as 3rd party hooks cannot work with sequelize instances.

Hope that helps anybody else coming here. If you still have questions, come to the “sequelize” room in Feather’s Slack.

1reaction
musicformellonscommented, Dec 29, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

feathers-sequelize does not work with ```raw: false``` anymore ...
After adding a dehydrate hook (as an after hook) the output is as expected. It's not clear to me why before upgrading this...
Read more >
Can not get registered user after upgrading to Buzzard · Issue #759 ...
Everything seems to work now except that I can not get the user that ... Model; hook.params.sequelize = { raw: false, include: [{...
Read more >
One year ago today, Mercy the Buzzard debuted on Raw ...
I was so disappointed when I saw Bray Wyatt debut in the Firefly funhouse. I am very happy with how wrong I ultimately...
Read more >
Buzzard's Beat - There is a post going around that attributes ...
That reasoning is absolutely false. Malarky. The actual reason for color difference (from a PhD meat scientist I know) is: "The one in...
Read more >
What Not To Serve Buzzards For Lunch, A Glorious Science ...
The painting, curiously, helped solve the puzzle, which is: How do vultures find food? James Audubon stairs at at vulture in a tree....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found