rclai / meteor-ddp-inspector

Allows you to see all DDP activity in the client-side.
https://atmospherejs.com/lai/ddp-inspector
23 stars 4 forks source link

Fix unknown method name error #4

Closed MasterAM closed 9 years ago

MasterAM commented 9 years ago

It is possible that messages (including method calls) are sent before the package is initialized.

Currently, in this case we get an error in the methodName template helper, that is unable to get the method name when a result arrives.

In my case, autoupdate, accounts-base and ddp itself send messages before ddp-inspector wraps the ddp methods.

It currently seems that there is no reasonable way to force the package to load before certain packages, as noted in https://github.com/meteor/meteor/issues/3781 (and even if there were, it could complicate the dependency graph).

It might be possible to get the method name from the ddp connection's _outstandingMethodBlocks, which contains methods that have outstanding callbacks.

My current solution is to cache those method names when the package loads. If the method call is not registered by ddp-inspector (and therefore it is not in the collection), we try searching for it in the cache, and if that fails, display (unknown method).

rclai commented 9 years ago

Thanks @MasterAM, I was dealing with this problem myself and couldn't figure out how to deal with it.

I'm going to clean the code up and then push an update soon.

MasterAM commented 9 years ago

Great.