Menu

Post image 1
Post image 2
1 / 2
0

Your AI Is Still Billing After the User Closed the Tab

DEV Community·AdmilsonCossa·24 days ago
#pDIQE02n
Reading 0:00
15s threshold

That’s not a bug. It’s a missing owner. The user closed the browser 30 seconds ago. Your logs show the response was never delivered. But the LLM stream is still running. The vector search is still scanning. The rerankers are still scoring. The tool calls are still executing. The invoice will arrive tomorrow. This is not hypothetical. It is the default behavior of many AI backends today. app . post ( " /chat " , async ( req , res ) => { const stream = await openai . chat . completions . create ({ model : " gpt-4.1 " , stream : true , messages : req . body . messages , }); for await ( const chunk of stream ) { res . write ( chunk . choices [ 0 ]?. delta ?. content ?? "" ); } res . end (); }); Enter fullscreen mode Exit fullscreen mode This code looks completely reasonable. It even works — until the user refreshes the page, closes the tab, loses signal, or navigates away. At that moment: the HTTP response is dead the client no longer exists the user no longer cares But the async work often continues anyway.…

Continue reading — create a free account

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

Read More