diff --git a/.changeset/clean-plums-tap.md b/.changeset/clean-plums-tap.md new file mode 100644 index 000000000000..010cf1a31824 --- /dev/null +++ b/.changeset/clean-plums-tap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Destroy the server response stream if async error is thrown diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index b2a60f90ef77..ee9aa0d60c63 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -153,8 +153,10 @@ export class NodeApp extends App { } destination.end(); // the error will be logged by the "on end" callback above - } catch { - destination.end('Internal server error'); + } catch (err) { + destination.write('Internal server error', () => { + err instanceof Error ? destination.destroy(err) : destination.destroy(); + }); } } }