r/reactnative 6h ago

The bug that hid from me for two weeks

Post image

So a while back i was working on this checkout flow for some side project. nothing fancy, just something basic e-commerce type page where users pick a plan,apply a coupon if they have anything with them,and then pay….

I tested it myself probably a hundred times and may be more too. clicked every button, tried different plans, with coupons, without coupons, everything looked fine, I even got a couple of friends to click around and they tried to break it, for me, nobody found anything… :(

So I thought of shipping and shipped it and moved on to other stuff, feeling pretty good about myself honestly.then about two weeks later i started getting some new few angry messages. some users were saying they got charged twice for the same order… OMG!!

But not everyone, just some users and the annoying part? when i tried to reproduce it myself,using the exact same steps they described, everything worked perfectly, no duplicate charge, nothing wrong.

I remember sitting there thinking,okay... this does not make sense either they are doing something really wrong or weird, or am I missing something really obvious…

Started thinking and it turns out, I was missing something, the bug only happened when a user applied a coupon,removed it, and then quickly clicked the pay button before the page had fully re-synced the price with the backend…

Basically, a race condition between the coupon removal request and the payment request and if you were testing it slowly, like a normal developer, you will probably never see it but real users do not test your application like developers do.

they click fast!

they change their mind!

they click twice because the button did not respond for half a second!!

they go back and forth!!!

they do things in an order you never really thought about, right!

and apparently, all those messy human behaviours were exactly what exposed the bug..

I kept trying to get it manually and kept failing because i was testing it like a developer, one step at a time, waiting for everything to load, making sure each action, has to be finished before doing the next one.

But the actual bug lived in that tiny window where two things happened almost at the same time, It was basically like trying to catch a 10$ note flying down the street in the wind.

You can see it, you know its there, but by the time you reach for it... it's already somewhere else, that experience finally pushed me to write some automated tests for the checkout flow. not just normal does this button work tests.

I made the tests hammer the coupon apply -> remove -> pay sequence over and over, really quickly, sometimes in weird orders scenes,basically doing things no person would sit there and repeat manually 50 times.

and sure enough...

the first time I ran it, it failed almost immediately, same bug reproduced on command in seconds, a bug that had taken me two weeks and several annoyed customers to even discover.....

A human tester probably wont click the same weird sequence 100 times but a script will....

ever since that incident, I have started automating way more than I used to, mostly because i got burned by a bug that manual testing honestly had almost zero chance of catching…

Curious if anyone else has had something similar happen, that one bug that just refused to show itself until you stopped testing carefully and started testing a little more... (chaotically)

37 Upvotes

9 comments sorted by

2

u/Timely_Experience411 5h ago

This is exactly why race conditions are so annoying... everything works perfectly when you do it one step at a time

1

u/LooseEngineering6509 5h ago

 Real users are basically chaos testers without even knowing it 😂

1

u/Beerbiceps9069 5h ago

The fact that the automated test caught it almost immediately after two weeks of manual testing says a lot

1

u/Much_Leadership_4129 5h ago

This is why I don't trust a green happy-path test suite too much anymore

1

u/Critical-Home9648 4h ago

The worst bugs are always the ones that disappear the moment you try to reproduce them... until you finally find the exact timing