fix(server): stop reporting work cancelled by a disconnected client (#19037)

A route that aborts its storage read when the response closes rejects with
AbortError after the client has gone. The error handler reported that
cancellation as a server crash. Skip the error sinks for an AbortError when
the response was closed before it finished; report it otherwise.

Fixes PAPERCLIP-BACKEND-5A

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Devin FoleyandClaude Opus 5.5 authored and GitHub committed 2026-11-06 00:39:27 -08:00
1 parent b400914345
commit 2c7ee84221
2 files changed
+110

No files matched your search

+10
View File
@@ -298,6 +298,16 @@ export function errorHandler(
return;
}
// A route that cancels its work when the response closes (for example a
// storage read) rejects with AbortError after the client has gone. That
// rejection is the cancellation, not a server fault. An AbortError while
// the client is still connected is still reported.
if (rootError.name === "AbortError" && res.destroyed && !res.writableFinished) {
if (!res.headersSent) res.status(499);
res.end();
return;
}
// Shutdown drains the HTTP listener before it ends the pool, but a handler
// whose client already disconnected (or whose socket the drain timeout
// closed) keeps running. Its next query then fails with CONNECTION_ENDED