From 399cb6b0dd2104224c0ef0ce8e92f84e4f7faf42 Mon Sep 17 00:00:00 2001 From: Jan Kaiser Date: Thu, 27 Feb 2025 06:28:52 +0100 Subject: [PATCH] fix missing cleanup, if response socket is no longer writeable (issue 1547) (#1593) Relates to issue #1547, see my [comment there](https://github.com/koajs/koa/issues/1547#issuecomment-908370552) Co-authored-by: Jan Kaiser Co-authored-by: titanism <101466223+titanism@users.noreply.github.com> --- lib/application.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/application.js b/lib/application.js index 4d170b049..6867b9eef 100644 --- a/lib/application.js +++ b/lib/application.js @@ -258,9 +258,10 @@ function respond (ctx) { // allow bypassing koa if (ctx.respond === false) return - if (!ctx.writable) return - const res = ctx.res + + if (!ctx.writable) return res.end() + let body = ctx.body const code = ctx.status