Here is the code that allowed someone to double wirhdraw from nodeless.

Can you spot why this doesn't work?

Reply to this note

Please Login to reply.

Discussion

I’m not a programmer so this is a guess

Is it because the first “withdrawal” line is related to User ID, but the “withdrawal lock” line relates to User Email?

Again, not trained here but looking for discrepancies…

Nah, one is a key inside a rate limiter, the other is just for logging so I can see it. Doesn't affect the bug

Makes sense. Thanks for the feedback 🤙

This is what our friend GPT-4 said:

Yup that's right. And basically how it was fixed

`withdrawal_lock` wasn't set, or was set to a non-boolean?

It gets set later in the code before the withdrawal happens

The if clause for that env var is empty. It should have returned or thrown an error.

Lol yes but no, didn't want to globally disable withdrawals in this case

I can’t see where you set the lock. It’s possible the lock was never set.

Lock does get set, but apparently not fast enough if two requests come in concurrently :/

Big problem was app is running serverless, so requests can process at identical time before database actually records it 😅

missed the return, homie

Lol nah that's on purpose

I’m surprised no one said it: PHP

PHP is awesome now, give it another try!! Ain't your 2004 PHP!!

I love PHP but I don’t use it anymore

I thought about it but felt bad lol

deeply considered “php is a hell of a drug” 😂

`withdrawal_lock` was not set?

In a sense yes, but it was not set due to concurrent requests, not due to the code not setting it

I see that now... what's the purpose of `sleep` statement when you already have the `RateLimiter`?

So that the rate limiters have lower odds of being fired at the same time.

Didn't work, though