Skip to content

Commit

Permalink
wip: fix reentrant error with ReadableStreams in RSC
Browse files Browse the repository at this point in the history
  • Loading branch information
jplhomer committed Jan 19, 2022
1 parent f7adeb8 commit 2ea3f3a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/hydrogen/src/foundation/ShopifyProvider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/foundation/ShopifyProvider and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->

The `ShopifyProvider` component wraps your entire app and provides support for hooks.
You should place it in your app's entry point component. For example, `&lt;App&gt;`.

## Example code

```tsx
import {ShopifyProvider} from '@shopify/hydrogen';
import shopifyConfig from '../shopify.config';

export default function App() {
return (
<ShopifyProvider shopifyConfig={shopifyConfig}>
{/* Routes, Pages, etc */}
</ShopifyProvider>
);
}
```

## Component type

The `ShopifyProvider` component is a shared component, which means that it renders on both the server and the client. For more information about component types, refer to [React Server Components](/custom-storefronts/hydrogen/framework/react-server-components).
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,10 @@ function performWork(request) {
}
}

let reentrant = false;
function flushCompletedChunks(request, destination) {
if (reentrant) return;
reentrant = true;
try {
// We emit module chunks first in the stream so that
// they can be preloaded as early as possible.
Expand Down Expand Up @@ -893,6 +896,7 @@ function flushCompletedChunks(request, destination) {

errorChunks.splice(0, i);
} finally {
reentrant = false;
}

if (request.pendingChunks === 0) {
Expand Down

0 comments on commit 2ea3f3a

Please sign in to comment.