-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser DDP call promise never resolves #20
Comments
It seems it has something to do with the way arguments are sent. I tried server.call("hello", 5) // never resolved, meteor method code never executed
server.call("hello", [5]) // did resolve, method executed |
The other problem i'm seeing is: This works:
Meteor.methods({
hello (limit = 5) {
// do some database work
return [{
hello: "true"
}]
}
})
server.call('hello', [5] ) This does not work:
Meteor.methods({
hello (limit = 5) {
// do some database work
const things = Things.find(myQuery).fetch()
// actually return an array of items from the database, DONT WORK
return things
}
})
server.call('hello', [5] ) |
I found something that seems to nail what the problem is, although i don't know the solution yet: This does not work:
Meteor.methods({
hello (limit = 5) {
// do some database work
const things = Things.find(myQuery).fetch()
// actually return an array of items from the database, DONT WORK
return things
}
})
server.call('hello', [5] ) This works on both, Meteor Application and simpleDDP. Meteor.methods({
hello (limit = 5) {
// do some database work
const things = Things.find(myQuery).fetch()
// actually return an array of items from the database, DONT WORK
return JSON.parse(JSON.stringify(things))
}
})
server.call('hello', [5] ) A funny thing is that, debugging ``` socket.on("message:in", function (message) {```` Won't receive a message with There is something wrong about the communication that for some reason the |
I just tried exactly same code on node.js:
if i JSON.parse(JSON.stringify(response)) Then it works as expected on node.js and on the browser. The puzzling thing is that my Meteor application works as expected. I'm using Meteor 1.8.1 Have you experienced anything similar? I'll give up on debugging it further because I need to carry on with my app, let me know if you have experienced something similar or have an idea on how to fix it. I can provide you with a sample app privately if you let me know your email. |
Really strange issue with |
You can create a secret gist of your Meteor method and your simpleDDP code then send me the link here [email protected] |
I've got the same problem. Fortunately for me, I only got problems when requesting certain documents. Upon comparing the difference with other document, I found the problematic ones got ObjectIDs from workers using mongoose outside of Meteor. The DDP client seems have trouble parsing non standard data object, hence JSON.stringify/JSON.parse can mitigate the problem. You may want to check if this is the case. |
It could be possible. Both import EJSON from 'ejson';
class MongoObjectId {
constructor(value) {
this.value = value;
}
// Convert our type to JSON.
toJSONValue() {
return this.value;
}
// Unique type name.
typeName() {
return 'oid';
}
}
EJSON.addType('oid', function fromJSONValue(str) {
return new MongoObjectId(str);
}); Do it before creating |
Turns out this was a bug on my abstraction ( as you could imagine ), so that's solved for me. |
Yes indeed it seems to be something related to this issue. The funny part tough is that Meteor version of the DDP Client don't have this issue ( as i said, the same subscription that got stuck for me with DDPClient did not get stuck on the Meteor Client), i wonder if there is an easy way to "copy" the solution Meteor DDP uses and implement it on the DDP Client transparently? |
@hems I think it will be easier if you publish here the structure with data types of the object because I am not sure about easy copying of all custom ejsons :( |
Good work on the package and plugins architecture ( :
Currently i tried:
But funny enough, when i tried to do a simple call to some method the returned promise never resolves.
I investigated a bit of the source code ( specifically the apply method ) and turns out:
methodId
value is0
onMethodResult
is never calledThen basically the promise hangs forever and never resolves.
I have some Meteor "native code" using that same
Meteor.method
and it works normally, so i can confirm it's not a problem on the meteor side.I'll let you know if I find any other clues about what might be causing that problem.
The text was updated successfully, but these errors were encountered: