meteor / meteor-feature-requests

A tracker for Meteor issues that are requests for new functionality, not bugs.
Other
89 stars 3 forks source link

Change the ordering of fields in the `method` DDP message #427

Closed radekmie closed 3 years ago

radekmie commented 3 years ago

While there's a couple of excellent tools to debug the DDP communication, I still tend to rely on the browser's Network tab. In this case, I can't see the whole DDP messages but a short prefix instead. It's fine for all but one message: method.

For example, if I'd like to check whether a subscription is ready, the id of a subscription is the second key both in the sub and ready messages (source, source). Similarly, added/changed/removed maintain the order of msg, collection, id - the exact one we care about.

Now, let's get to methods. The result is fine (source, source), but for some reason, method is not - it sends the id last.

My proposal is to move the id sent in the method message to the second or third position:

     const message = {
       msg: 'method',
+      id: methodId,
       method: name,
-      params: args,
-      id: methodId
+      params: args
     };
StorytellerCZ commented 3 years ago

That sounds reasonable to me. Go ahead and create a PR, I think this will be a small change and since it is an object it shouldn't affect anything function wise.