Skip to content

Commit 9c4978b

Browse files
Merge pull request #358 from Shopify/add-gotcha
Add a gotcha for streaming responses
2 parents 449869e + 6bab38c commit 9c4978b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ When you reach the step for [setting up environment variables](https://shopify.d
151151

152152
When hosting your Shopify Remix app on Vercel, Vercel uses a fork of the [Remix library](https://github.com/vercel/remix).
153153

154-
To ensure all global variables are set correctly when you deploy your app to Vercel update your app to use the Vercel adapter instead of the node adapter.
154+
To ensure all global variables are set correctly when you deploy your app to Vercel update your app to use the Vercel adapter instead of the node adapter.
155155

156156
```diff
157157
// shopify.server.ts
@@ -216,6 +216,7 @@ pnpm run deploy
216216

217217
This template registers webhooks after OAuth completes, using the `afterAuth` hook when calling `shopifyApp`.
218218
The package calls that hook in 2 scenarios:
219+
219220
- After installing the app
220221
- When an access token expires
221222

@@ -228,7 +229,7 @@ That will force the OAuth process and call the `afterAuth` hook.
228229

229230
Webhooks subscriptions created in the [Shopify admin](https://help.shopify.com/en/manual/orders/notifications/webhooks) will fail HMAC validation. This is because the webhook payload is not signed with your app's secret key.
230231

231-
Create [webhook subscriptions]((https://shopify.dev/docs/api/shopify-app-remix/v1/guide-webhooks)) using the `shopifyApp` object instead.
232+
Create [webhook subscriptions](https://shopify.dev/docs/api/shopify-app-remix/v1/guide-webhooks) using the `shopifyApp` object instead.
232233

233234
Test your webhooks with the [Shopify CLI](https://shopify.dev/docs/apps/tools/cli/commands#webhook-trigger) or by triggering events manually in the Shopify admin(e.g. Updating the product title to trigger a `PRODUCTS_UPDATE`).
234235

@@ -251,6 +252,19 @@ When you trigger a webhook event using the Shopify CLI, the `admin` object will
251252

252253
Webhooks triggered by the CLI are intended for initial experimentation testing of your webhook configuration. For more information on how to test your webhooks, see the [Shopify CLI documentation](https://shopify.dev/docs/apps/tools/cli/commands#webhook-trigger).
253254

255+
### Using Defer & await for streaming responses
256+
257+
To test [streaming using defer/await](https://remix.run/docs/en/main/guides/streaming) during local development you'll need to use the Shopify CLI slightly differently:
258+
259+
1. First setup ngrok: https://ngrok.com/product/secure-tunnels
260+
2. Create an ngrok tunnel on port 8080: `ngrok http 8080`.
261+
3. Copy the forwarding address. This should be something like: `https://f355-2607-fea8-bb5c-8700-7972-d2b5-3f2b-94ab.ngrok-free.app`
262+
4. In a separate terminal run `yarn shopify app dev --tunnel-url=TUNNEL_URL:8080` replacing `TUNNEL_URL` for the address you copied in step 3.
263+
264+
By default the CLI uses a cloudflare tunnel. Unfortunately it cloudflare tunnels wait for the Response stream to finish, then sends one chunk.
265+
266+
This will not affect production, since tunnels are only for local development.
267+
254268
## Benefits
255269

256270
Shopify apps are built on a variety of Shopify tools to create a great merchant experience.

0 commit comments

Comments
 (0)