Throttling calls to a server function in NextJS
I have a server function that can poll if a long-running event (Ethereum transaction being mined) has completed yet.
The actual request checking the blockchain is obviously also async and can take a second or two.
If someone hits the page when the transaction result hasn't already been stored in the db, their client will start calling a function on the server to check the status and update the db on success.
If multiple people are on this page, I don't really want to poll the blockchain excessively, so I want to early exit from calls to the server function that happen too often.
Will this approach work?
Asking because I'm not sure if all clients share the same server instance, so I don't know if
lastInvocationTimes
will always be correct?
I'm using NextJS on vercel0 Replies