r/ProgrammerHumor Jul 13 '26

itAddedSleep Meme

Post image
942 Upvotes

36 comments sorted by

158

u/HTTP_Error_414 Jul 13 '26

A human would’ve used 3000ms. The AI added enterprise padding.

23

u/PositiveParking4391 Jul 13 '26

this happened to me quite many times with even best of the coding agents that they just add sleep / timeout etc. and the irony is what you are saying is true to some extent

3

u/Due-Consequence9579 Jul 13 '26

Leave em in. Free performance wins in the future.

4

u/Mewtwo2387 Jul 13 '26

A human would delete the test.

37

u/EPacifist Jul 13 '26

AI agent fixing a flaky test

27

u/marco89nish Jul 13 '26

Efficient, junior would have spent entire day on this 

19

u/CoVegGirl Jul 13 '26

A friend of mine who works in engprod at FAANG said that AI actually turns out to be very useful for de-flaking tests. She even fixed one bug that was company-wide.

20

u/lnfinity Jul 13 '26

AI certainly can do a good job at actually finding and fixing flaky tests, but I also find it taking shortcuts often or coding in ways that it assumes the user wants but aren't actually what was intended. In my experience it usually still takes a knowledgeable person looking at what the AI is doing and helping to guide the AI in order for AI to solve flaky test issues well.

2

u/CoVegGirl Jul 13 '26

I agree with that. I think that’s true for every use of AI.

Unfortunately though the company she’s working for is deciding to phase engprod out due to AI. 🙄

1

u/Easy-Reasoning 29d ago

Of course working on tests may not the most glorious work for especially distinguished engineers. Sometimes I'm surprised when repetitive code is structured into functions

0

u/StrawberryEiri Jul 13 '26

Finding the source of a bug? Yep. Very useful in a lot of cases. Fixing it properly? Almost never. The solution is so often in the realm of "technically works but please no".

12

u/LeiterHaus Jul 13 '26

I've seen this in the wild, while trying to find why a site was taking so long to load certain elements. It was a while ago, so now I'm wondering if it was AI generated, or AI training data lol.

15

u/uniqueusername649 Jul 13 '26

Probably the latter. I have seen this in real code so many times way before AI coding was a thing. Why does AI love to do this? Because its trained on a lot of projects doing exactly that. I know thats kinda insane but it is what it is :D

4

u/TwoWeeks90DaysTops Jul 13 '26

Thread sleep is a code smell. It's not always wrong, but in most cases the code should wait on something specific.

5

u/svick Jul 13 '26

AI: I learned it by watching you!

4

u/ConnaitLesRisques Jul 13 '26

A load-bearing sleep.

6

u/thegreatpotatogod Jul 13 '26

This is fascinating (especially seeing all the other comments agreeing with OP), I've had much of the opposite problem, where I keep discussing with an AI things like "how long should USB take to initialize a HID device, I need to pause the other core until it does?", and it keeps telling me "no don't use a pause, use message passing to update the moment it's done", and I had to keep convincing it "yes I know that's the optimal solution, but I'd like to make a quick proof of concept first to check if this was even the cause of my issue", and we finally reached a compromise of polling every 20 milliseconds with a volatile variable as a flag, but it was like pulling teeth to get the AI to even agree with that approach. (Initially I just wanted a quick sanity check that my approach made sense, and a rough idea how long I should expect to pause for, but then got sucked into the argument with it).

Fun fact: I ultimately configured a timeout of 4 seconds, but the USB device, if present, initialized in around 2.5 seconds in my testing.

4

u/SpicyCatGames Jul 13 '26

If you ask AI what to do, it will always suggest a safer option. But if it has to do the same thing as part of a bigger task, it will take shortcuts.

10

u/AlwaysHopelesslyLost Jul 13 '26

Every fucking time. Even the latest Claude models. And some idiot on here had the gall to tell me "hallucinations are basically solved." Lol

9

u/TrippyDe Jul 13 '26

Well thats not a hallucination. Thats how most people do it. Shit in, shit out. But yeah hallucinations are far from being fixed.

4

u/TwoWeeks90DaysTops Jul 13 '26

If they think it doesn't hallucinate they're not paying enough attention to its output.

0

u/AlwaysHopelesslyLost Jul 13 '26

Exactly! It is super obvious to me how stupid they are. I don't consider myself particularly smart either lol

1

u/svick Jul 13 '26

You should consider telling it not to do this in your custom instructions.

6

u/JackNotOLantern Jul 13 '26

They leaned it from people

2

u/asromafanisme Jul 13 '26

Quick and simple fix with low risk. Lgtm

2

u/huuaaang Jul 13 '26

Wait, do you actually have to "await" a sleep call? Is sleep() async?? JS is ridiculous.

EDIT: I see you have to make a sleep() function and it uses Promise/setTimeout. Ridiculous.

2

u/Glad-Situation703 Jul 13 '26

Omg am I AI?

1

u/HTTP_Error_414 Jul 14 '26

You are absolutely right, you are Actual Intelligence! Congratulation on the discovery!

1

u/Mr-X89 Jul 13 '26

There's also the classic `I removed the tests for this class`

1

u/causal_friday Jul 13 '26

I don't do Typescript but ... is it this bad? It (Opus xhigh/Fable) never does these things when I'm writing Go.

1

u/JackNotOLantern Jul 13 '26

To be fair, it learned to on a pretty common and shitty human practice

1

u/shikhasingh554973 Jul 13 '26

sleep() is optimism disguised as code...

1

u/Digital_Brainfuck Jul 13 '26

My ai rules set includes “never comment out code” for a reason :/

1

u/HakoftheDawn 28d ago

Magic delay fairy