From 5986517b4f29af90fcfe333d4bb69ac09d4f8778 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 8 Sep 2022 12:30:49 -0400 Subject: [PATCH] Make React integration work with Deno (#4679) * Remove removed packages folder * fix * Add a changeset --- .changeset/orange-llamas-play.md | 5 +++++ package.json | 1 - packages/integrations/react/server.js | 15 +++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changeset/orange-llamas-play.md diff --git a/.changeset/orange-llamas-play.md b/.changeset/orange-llamas-play.md new file mode 100644 index 000000000..04c0e5ae4 --- /dev/null +++ b/.changeset/orange-llamas-play.md @@ -0,0 +1,5 @@ +--- +'@astrojs/react': patch +--- + +Prevent decoder from leaking diff --git a/package.json b/package.json index 99c018fee..5505eb045 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "packages/*", "examples/*", "examples/component/demo", - "examples/component/packages/*", "scripts", "packages/astro/test/fixtures/component-library-shared", "packages/astro/test/fixtures/custom-elements/my-component-lib", diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index 76e7f01e7..3dd2a3cbc 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -144,10 +144,17 @@ async function readResult(stream) { let result = ''; const decoder = new TextDecoder('utf-8') while (true) { - const { done, value } = await reader.read(); - if (done) { - return result; - } + const { done, value } = await reader.read(); + if (done) { + if(value) { + result += decoder.decode(value); + } else { + // This closes the decoder + decoder.decode(new Uint8Array()); + } + + return result; + } result += decoder.decode(value, { stream: true }); } }