meteor / meteor-feature-requests

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

Add Timestamp to Incoming DDP Requests #338

Open evolross opened 5 years ago

evolross commented 5 years ago

I'm opening this issue to track it. I may work on a PR myself as this should be a fairly straightforward feature to add.

I'd like to add a timestamp for when a Meteor server receives a DDP request from a client, specifically a Meteor method call request to run a Meteor method on the server.

I have a use-case where it would be optimal to know exactly when a request is received by the server, not when it is actually ran which can easily be found by calling Date.now() in the method code.

When I check the headers inside the scope of a Meteor method's code using gadicc:meteor-headers, there are several HTTP-style headers included but not a timestamp.

It would be great if Meteor timestamped requests as they're received in the DDP server code. This would return a more accurate time the request was actually received by the server, versus waiting for processing and other queues requests, and then getting a timestamp.

mitar commented 5 years ago

And what is the use case for this? Why do you need this?

evolross commented 5 years ago

The use-case is I'm trying to determine the timestamp (in server time) that a user sends a response from something that was initially sent to them (I already have the "sent" value on the server). I want to know, precisely as possible, how long it takes the user to send a response back to the server which currently is implemented using a Meteor method.

Waiting to call Date.now() in method code is prone to inaccuracy due to server traffic/queue-processing, etc. Having a timestamp for when the request was received, while still being prone to server busyness I assume, would be more accurate than waiting until processing. As the server would still be queuing requests accurately all the way up until it's pegging right?

Unfortunately a value can't simply be sent from the client because their clock may be off and there is a trust issue as well.