From 042e6f0d8b12da963a3ba9e4e65c66dd745b4d7f Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 25 Aug 2021 17:41:11 -0400 Subject: [PATCH 1/3] set rawBody to null when body is nullish in simulated load fetch (#2294) --- packages/kit/src/runtime/server/page/load_node.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/kit/src/runtime/server/page/load_node.js b/packages/kit/src/runtime/server/page/load_node.js index 41ac5f0007a7..70b9c61dcf1a 100644 --- a/packages/kit/src/runtime/server/page/load_node.js +++ b/packages/kit/src/runtime/server/page/load_node.js @@ -151,7 +151,10 @@ export async function load_node({ method: opts.method || 'GET', headers, path: relative, - rawBody: new TextEncoder().encode(/** @type {string} */ (opts.body)), + rawBody: + opts.body == null + ? null + : new TextEncoder().encode(/** @type {string} */ (opts.body)), query: new URLSearchParams(search) }, options, From 32f5cce4f0bfac032d4bdbb39ba272b32c1c3559 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 25 Aug 2021 17:49:37 -0400 Subject: [PATCH 2/3] add changeset --- .changeset/polite-donkeys-learn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/polite-donkeys-learn.md diff --git a/.changeset/polite-donkeys-learn.md b/.changeset/polite-donkeys-learn.md new file mode 100644 index 000000000000..568c7b84d178 --- /dev/null +++ b/.changeset/polite-donkeys-learn.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +avoid setting rawBody/body to an empty Uint8Array when a load's fetch function is called with no body during SSR From a140832718a0bd8ba5abe1b2853d001e9ba04339 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 25 Aug 2021 20:34:37 -0400 Subject: [PATCH 3/3] remove unneeded type cast --- packages/kit/src/runtime/server/page/load_node.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/kit/src/runtime/server/page/load_node.js b/packages/kit/src/runtime/server/page/load_node.js index 70b9c61dcf1a..800a29feede4 100644 --- a/packages/kit/src/runtime/server/page/load_node.js +++ b/packages/kit/src/runtime/server/page/load_node.js @@ -151,10 +151,7 @@ export async function load_node({ method: opts.method || 'GET', headers, path: relative, - rawBody: - opts.body == null - ? null - : new TextEncoder().encode(/** @type {string} */ (opts.body)), + rawBody: opts.body == null ? null : new TextEncoder().encode(opts.body), query: new URLSearchParams(search) }, options,