我在我的服务器上使用feathersjs (带有websockets)和sequelize,并升级到Buzzard版本。这个钩子在我的服务器上,在升级之前工作正常:`
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);
};
};升级后,当从客户端调用时使用:api.service('users').get(2, {query: {include: true}})
我得到这个错误(顺便说一下:当我省略内部include: [{ model: pointsModel }]时,同样的错误仍然存在):
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当我注释掉raw: false,时,它会给出正确的输出。我检查过了,但在我的‘升级前版本’中,当我没有使用raw: false,时,查询也可以工作,但是当它被添加时,输出结构是不同的(更嵌套的),所以我认为sequelize只是被绕过了,可能没有急切加载等。所以我喜欢使用raw: false,
升级服务器的Package.json后:
"@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",在服务器上升级Package.json之前:
"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",我的问题是:为什么它不再与raw: false,一起工作,我如何解决这个问题?
发布于 2017-12-29 22:23:25
添加dehydrate hook (作为After钩子)后,输出与预期一致。我不清楚为什么在升级之前这不是一个问题。
https://stackoverflow.com/questions/48005984
复制相似问题