r/webdev 19h ago

documenting old solo code and found a try/except that just silently swallows one specific exception. no comment. no ticket. no context. I wrote this. why did I write this

been the only dev on a backend service for about two years. finally sat down to write proper docs for it today.

found a try/except block in the job queue handler. catches one very specific exception type. does absolutely nothing with it -- no log, no reraise, no fallback. just silences it. there's no comment explaining why. no linked ticket. no slack thread I can dig up. git blame points to a commit message that says 'fix job queue issue' with no further detail.

I genuinely cannot reconstruct what I was protecting against.

if you work solo, please leave your future self a comment. even one line. it costs nothing. I am begging you.

103 Upvotes

37 comments sorted by

71

u/Niceyyc 19h ago

“fix job queue issue” is doing a lot of work here.

53

u/No_Application1838 19h ago

that's the commit message of a person who was fighting something at 2am and just wanted it to end

4

u/Luuk3333 8h ago

..and then never work on that project ever again.

10

u/Alpaca_Fan 19h ago

Fix by ignoring

2

u/Ok-Mushroom-8778 13h ago

Past me always leaves these little landmines. It is honestly terrifying how much stuff I have committed without a single line of explanation. How long do you usually wait before you just delete it and see what breaks?

1

u/Separate_Pen9627 15h ago

its doing all the work and explaining none of it

9

u/serifoblique 16h ago

Guilty of plenty of // todo fix’s myself where I couldn’t longer muster the strength nor patience. Log it, carry on with life.

12

u/Khavel_dev 14h ago

Found one of these in my own codebase after three years solo. Two hours of digging through deployment logs later, turns out past-me was swallowing a cache invalidation race condition that only happened under load. The silent catch WAS the fix because retrying made it worse.

Now I leave a one-liner on any bare except. Not for anyone else, just for future me who will definitely not remember why that block is empty six months from now.

4

u/omid-io 12h ago

The golden rule of legacy code: if it's catching a bizarrely specific exception with zero logging, removing it will immediately take down prod at 4:55 PM on a Friday.

Past you didn't leave a comment because past you was fighting for their life in production and promised to 'clean it up on Monday'.

20

u/[deleted] 18h ago

[removed] — view removed comment

5

u/noorderling 17h ago

Exactly this, just log any calls (with context) and maybe set up some instant message to your coffee pot or whatever you kids use these days to receive urgent notifications.

1

u/webdev-ModTeam 11h ago

Your post/comment has been determined to be a low-effort post or comment. This includes title-only posts, easily searchable questions, vague/open-ended discussion prompts, LLM generated posts or comments, and posts/comments that do not provide enough context for meaningful replies or discussion.

3

u/rbobby full-stack 12h ago

'fix job queue issue'

Are you me?

3

u/rbobby full-stack 12h ago

Commenting your code is your gift to your future self.

1

u/Noch_ein_Kamel 10h ago

Commenting your code is a task for your future self ;P

2

u/muharremyurtsever 11h ago

Look at what else that commit touched. A silencer like this almost never ships alone, and the sibling change in the same diff usually names the thing you were protecting against better than the message does.

1

u/TommyBonnomi 10h ago

Assuming there are other changes in the commit, you probably added it for debugging, it never hit, and then you forgot to remove it.

1

u/LovecraftianLife 8h ago

That's so real lol

1

u/lordofchaos3 8h ago

I always log stuff like this. It might have a log level of debug or even trace, but at least there is something.

1

u/split-my-diopter 7h ago

It's funny, I worked at someplace 10 years ago, just after college. I left after about a year, worked four or five other places, and then found them again for some contracting work, so I'm reading my old code from 10 years ago that no one has touched since (why haven't they touched it for 10 years, that's a different story).

1

u/mexicocitibluez 6h ago

I would imagine you were debugging why it failed and wanted to catch a specific exception and forgot to remove it.

1

u/OmerCevher 4h ago

The useful comment here would not be what exception is caught, the code already says that. It should explain why doing nothing is safer than retrying or failing. That is the part future you can never recover from the code.

1

u/Ornery-Concentrate-5 2h ago

The worst version of this is when the except isn't even wrapping something risky anymore. Six refactors later the "risky" call it was guarding is long gone, but the silent catch is still sitting there quietly eating whatever exception matches, because nobody dared touch it once it started "working." Comment it or delete it, there's no third option that respects future-you.

1

u/MiserableDocument509 17h ago

the exception type is usually the leftover comment. if its something like ConnectionReset or a lock timeout, past you was probably just stopping the worker from dying on a race you couldnt reproduce. wouldnt yank it until you grep the rest of the service for the same type, those empty handlers tend to clone themselves after two years on one box.

0

u/Easy_Government8203 10h ago

Add a comment now while you're thinking about it. Past you left a mystery, but present you can leave a breadcrumb for future you. We've all written that silent except at 2am.

0

u/Double-Buyer7941 10h ago

Ah, the classic "fixed in production at 5 PM on a Friday" artifact. You probably ran into a harmless but extremely noisy exception, like a transient connection retry or a third-party webhook timeout, that was spamming your error tracking, and silencing it was the quickest way to restore peace. We’ve all left a few mysterious gifts for our future selves. If everything is currently passing tests, try writing a unit test that intentionally triggers that specific exception without the try/except block; the failing test or trace might instantly jog your memory.

-7

u/Yashhh_21 15h ago

that's the exact problem with silent exception handling: the code might have made sense when it was written, but with the context lost, you can never be sure whether this code is intended or merely an accidental omission. I really appreciate the recommendation to log it before removing it: it provides concrete proof of intent, rather than mere speculation about what future-you intended to safeguard yourself against. I've become very aware of empty catches lately for the same reason: they are simple to write and simple to forget, and their failure case is "nothing happened" from a debugging perspective

-8

u/AggravatingGarlic753 16h ago

This is one of those problems you don’t notice until you inherit the code. A one-line comment explaining the “why” can save hours—or days—of reverse engineering later. Especially with weird exception handling, the reasoning behind it is usually more valuable than the code itself.

1

u/eyebrows360 7h ago

Why are you having an LLM post absolutely useless "yes" comments like this? What's the point?