How can I get the precise time at which a request is sent?

I'm looking to debug an issue and, for that, I need to know the exact time at which discord.js sends the request to Discord and the exact time it's received at, as well as any rateLimits that occurred in the way. I'm not too familiar with rest so I'd like to know if this is possible and where I can see the history of rateLimits on my code without having to listen to the rateLimit event from rest
7 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey2y ago
There is no history of rate limits stored anywhere rest events are the closest you'll get unless you want to start diving into internal source code to add additional debugging
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Rodry
RodryOP2y ago
there isn't a lot of documentation around this from what I saw, but I assume that event is fired when a response is received? Or is it when it's sent? yeah I would go into the source code but I need to debug this in production and it's not too easy to change an external package in prod seems like the response event is emitted when the response is received. I'll try to use that and the rateLimit event to see if I can figure something out also @ckohen since you replied to the issue, is that separate handler you mentioned something you're gonna PR into rest or is it something you will use to test yourself?
ckohen
ckohen2y ago
you can also use diagnostics channel to see when undici sends requests
Rodry
RodryOP2y ago
im not too familiar with how undici works, can you elaborate? link please
ckohen
ckohen2y ago
Node.js Undici
A HTTP/1.1 client, written from scratch for Node.js.
Want results from more Discord servers?
Add your server