Problems retrieving objects from seneca services


#1

Hi,

I’m having an issue with a Meteor application communicating with Seneca services on the backend.
It appears requests are being received but the object responses are not being received by Meteor, returning undefined.
The traceback is directly below.

Have anyone experienced this and/ or have any remedies/ ideas?

Thanks

John


Chrome:

myreach.js:284 {cmd: “rm”, did: “metaroot”, gid: “graph”}
myreach.js:279 undefined
meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:942 Exception in delivering result of invoking ‘metaroot.get’: TypeError: Cannot read property ‘id’ of undefined
at initDescriptor (htp://localhost:3000/app/app.js?hash=436cf9124e9edc4861036703e2a084bad6c56aa8:5592:37)
at htp://localhost:3000/app/app.js?hash=436cf9124e9edc4861036703e2a084bad6c56aa8:5869:7
at MethodInvoker._callback (htp://localhost:3000/packages/meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:1117:22)
at MethodInvoker.maybeInvokeCallback (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3682:12)
at MethodInvoker.receiveResult (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3702:10)
at Connection.livedata_result (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:4828:9)
at onMessage (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3528:206)
at htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:2908:9
at Array.forEach ()
at Function.
.each.
.forEach (htp://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11)

Meteor:

$ DEBUG=seneca meteor

[[[[[ /opt/msr/meteor ]]]]]

=> Started proxy.
=> Started MongoDB.
I20171104-15:40:38.969(-7)? ** You’ve set up some data subscriptions with Meteor.publish(), but
I20171104-15:40:38.994(-7)? ** you still have autopublish turned on. Because autopublish is still
I20171104-15:40:38.995(-7)? ** on, your Meteor.publish() calls won’t have much effect. All data
I20171104-15:40:38.995(-7)? ** will still be sent to all clients.
I20171104-15:40:38.995(-7)? **
I20171104-15:40:38.995(-7)? ** Turn off autopublish by removing the autopublish package:
I20171104-15:40:38.995(-7)? **
I20171104-15:40:38.995(-7)? ** $ meteor remove autopublish
I20171104-15:40:38.996(-7)? **
I20171104-15:40:38.996(-7)? ** … and make sure you have Meteor.publish() and Meteor.subscribe() calls
I20171104-15:40:38.996(-7)? ** for each collection that you want clients to see.
I20171104-15:40:38.996(-7)?
=> Started your app.

=> App running at: htp://localhost:3000/
I20171104-15:40:39.028(-7)? {“kind”:“notice”,“notice”:“hello seneca x8s70ga1ogy9/1509835238716/17763/3.4.3/-”,“level”:“info”,“seneca”:“x8s70ga1ogy9/1509835238716/17763/3.4.3/-”,“when”:1509835239027}

Seneca:

$ DEBUG=seneca node server.js

{“kind”:“notice”,“notice”:“hello seneca s6spggaqld2k/1509835247364/17765/3.4.3/-”,“level”:“info”,“seneca”:“s6spggaqld2k/1509835247364/17765/3.4.3/-”,“when”:1509835248006}
seneca/root.js msg: { role: ‘metaroot’,
cmd: ‘get’,
descriptor: { cmd: ‘rm’, did: ‘metaroot’, gid: ‘graph’ },
‘transport$’:
{ track: [ ‘x8s70ga1ogy9/1509835238716/17763/3.4.3/-’ ],
origin: ‘x8s70ga1ogy9/1509835238716/17763/3.4.3/-’,
time: { client_sent: ‘1509835299931’ } },
‘tx$’: ‘mgfjff9eae7j’ } +0ms
seneca/root.js add-msg { role: ‘metaroot’,
cmd: ‘add’,
descriptor: { cmd: ‘rm’, did: ‘metaroot’, gid: ‘graph’ },
‘transport$’:
{ track: [ ‘x8s70ga1ogy9/1509835238716/17763/3.4.3/-’ ],
origin: ‘x8s70ga1ogy9/1509835238716/17763/3.4.3/-’,
time: { client_sent: ‘1509835299960’ } },
‘tx$’: ‘25sljolbzkl6’ } +18ms
seneca/root.js add-obj $-/-/descriptor;id=;{did:metaroot,properties:{name:metaroot},targets:[],type:common} +1ms

meteor/server/methods.js:

import { Meteor } from ‘meteor/meteor’;
import debug from ‘debug’;

var dbg = debug(‘meteor/server/methods.js’);

var seneca = require(‘seneca’)().client().use(‘basic’).use(‘entity’);
var senecaAction = Meteor.wrapAsync(seneca.act, seneca);

Meteor.methods({

‘metaroot.get’: function( descriptor ) {
dbg( ‘metaroot.get’,descriptor );
let m = senecaAction( {role:‘metaroot’,cmd:‘get’,descriptor} );
if ( m.length==0 ) {
let m = senecaAction( {role:‘metaroot’,cmd:‘add’,descriptor} );
}

return m;

}

});

meteor/package.json:

{
“name”: “meteor”,
“private”: true,
“scripts”: {
“start”: “meteor run”
},
“dependencies”: {
“babel-runtime”: “^6.26.0”,
“debug”: “^3.1.0”,
“meteor-node-stubs”: “^0.3.2”,
“seneca”: “^3.4.3”,
“seneca-basic”: “^0.5.1”,
“seneca-entity”: “^2.0.2”,
socket.io”: “^2.0.4”
}
}

seneca/root.js:

var dbg = require(‘debug’)(‘seneca/root.js’);

module.exports = function metaroot() {
var seneca = this;

seneca.add( {role:‘metaroot’,cmd:‘get’},function getMetaroot( msg,done ) {
dbg( ‘msg:’,msg );
seneca.make$( ‘descriptor’ ).list$( {id:msg.descriptor.id},done );
});

seneca.add( {role:‘metaroot’,cmd:‘add’},( msg,done ) => {
dbg( ‘add-msg’,msg );
let m = seneca.make$( ‘descriptor’ );
m.did = ‘metaroot’;
m.properties = { name:‘metaroot’ };
m.targets = new Array();
m.type = ‘common’;
seneca.make$( ‘descriptor’ ).save$( m ).list$( {id:m.did},done );
dbg( ‘add-obj’,m );
});
};

seneca/package.json:

{
“name”: “seneca-server”,
“version”: “1.0.0”,
“description”: “combining seneca + meteor”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”,
“start”: “node server.js”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“debug”: “^3.1.0”,
“mongo-oplog”: “^1.1.0”,
“mongo-store”: “^0.0.2”,
“mongodb”: “^2.2.33”,
“seneca”: “^3.4.3”,
“seneca-basic”: “^0.5.1”,
“seneca-entity”: “^2.0.2”,
“seneca-mongo-store”: “^1.1.0”,
socket.io”: “^2.0.4”
},
“devDependencies”: {}
}


#2

If you put a 10 second timeout in the seneca service before calling done, does the meteor side immediately fail or wait 10 seconds before failing?


#3

Thanks for this tip, pward123

I can introduce an <= 5 second pause with the same result/ below, >5 causes a client timeout error.

myreach.js:284 {cmd: “rm”, did: “metaroot”, gid: “graph”}
myreach.js:279 undefined
meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:942 Exception in delivering result of invoking ‘metaroot.get’: TypeError: Cannot read property ‘id’ of undefined
at initDescriptor (htp://localhost:3000/app/app.js?hash=436cf9124e9edc4861036703e2a084bad6c56aa8:5592:37)
at htp://localhost:3000/app/app.js?hash=436cf9124e9edc4861036703e2a084bad6c56aa8:5869:7
at MethodInvoker._callback (htp://localhost:3000/packages/meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:1117:22)
at MethodInvoker.maybeInvokeCallback (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3682:12)
at MethodInvoker.receiveResult (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3702:10)
at Connection.livedata_result (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:4828:9)
at onMessage (htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:3528:206)
at htp://localhost:3000/packages/ddp-client.js?hash=df770fd9a6a02fd730939b97d266ea2b12938e95:2908:9
at Array.forEach ()
at Function.
.each.
.forEach (htp://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11)

Also, this functionality used to work in previous versions/ platforms, so I’m suspecting a breakage.

Thanks

John