Skip to content

Commit

Permalink
Make React integration work with Deno (#4679)
Browse files Browse the repository at this point in the history
* Remove removed packages folder

* fix

* Add a changeset
  • Loading branch information
matthewp committed Sep 8, 2022
1 parent 9290b24 commit 5986517
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-llamas-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/react': patch
---

Prevent decoder from leaking
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions packages/integrations/react/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}
Expand Down

0 comments on commit 5986517

Please sign in to comment.