Closed 170210 closed 9 months ago
There is no multithreading in a node.js app, so the issue is probably not the lock itself.
I think the main issue are those lines here: https://github.com/cosmos/cosmjs/blob/main/packages/faucet/src/api/webserver.ts#L86-L88. Since the await faucet.credit(address, matchingDenom)
call only returns when the transaction is in a block, the date is set too late. We should swap the two.
Thank you for your reply! I tried swapping these two commands, and it successfully prevented multiple requests.
Could you open a PR with that change?
Hello, I am trying to use cosmjs/faucet.
However, I have noticed that if I send the same request multiple times in a short period, either through CLI or the frontend, I can obtain multiple test coins, thereby bypassing the rule (https://github.com/cosmos/cosmjs/blob/main/packages/faucet/src/api/webserver.ts#L69-L77) set that one can only receive coins once within a certain period.
Is it necessary to implement a exclusive lock to prevent the same address from making multiple requests within a short period?