Menu

Timeout is not failure: the email bug every AI writes
📰

Timeout is not failure: the email bug every AI writes

DEV Community: typescript·Matteo Mazzocchi·22 days ago
#W7PD1fRO
#devtotypescript#devto#dev#email#code
Reading 0:00
15s threshold

I build back-office systems for small Italian companies: CRMs, booking flows, the boring machinery that sends the right email to the right person. I write most of that code with an AI assistant. I'm not hiding it, it's how I work.

And there is one bug my assistant writes almost every time, in every project, unless I stop it. It looks like good engineering. It passes the tests. And in production it sends your customer the same email twice.

The code that looks right

Ask an AI to "send the confirmation email, and make it robust", and you'll get something like this:

async function sendConfirmation ( booking : Booking ) { for ( let attempt = 1 ; attempt <= 3 ; attempt ++ ) { try { await emailProvider . send ( confirmationFor ( booking )); return ; } catch ( err ) { if ( attempt === 3 ) throw err ; await sleep ( 1000 * attempt ); } } }

Enter fullscreen mode

Exit fullscreen mode

Retries, backoff, a final throw. A reviewer would approve it. So would I, on a tired day.

The problem is hidden in that catch .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.