From e4061de6296d70da853eca9729092a43aeab7884 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Mon, 23 Oct 2023 22:37:51 +0300 Subject: [PATCH] fix(server): use Response ctor if Response.error not implemented --- .changeset/three-laws-care.md | 5 +++++ packages/server/src/plugins/useErrorHandling.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/three-laws-care.md diff --git a/.changeset/three-laws-care.md b/.changeset/three-laws-care.md new file mode 100644 index 00000000000..d3614fbb75b --- /dev/null +++ b/.changeset/three-laws-care.md @@ -0,0 +1,5 @@ +--- +'@whatwg-node/server': patch +--- + +If Response.error is not implemented, use Response ctor directly diff --git a/packages/server/src/plugins/useErrorHandling.ts b/packages/server/src/plugins/useErrorHandling.ts index 9d6a9faebae..cc710b88013 100644 --- a/packages/server/src/plugins/useErrorHandling.ts +++ b/packages/server/src/plugins/useErrorHandling.ts @@ -16,7 +16,10 @@ export function createDefaultErrorHandler( ); } console.error(e); - return ResponseCtor.error(); + if (ResponseCtor.error) { + return ResponseCtor.error(); + } + return new ResponseCtor(null, { status: 500 }); }; }