Server-side network request developer tool (unstable) #1314
Closed
wizardlyhel
announced in
Request for Comment
Replies: 3 comments 1 reply
-
This is a wonderful addition. Begins to answer many questions we've had running Hydrogen sites.
Thanks for pulling this together, helps us greatly. |
Beta Was this translation helpful? Give feedback.
1 reply
-
This will be very useful for errors that are hard to find in the stack |
Beta Was this translation helpful? Give feedback.
0 replies
-
Available in Doc: https://shopify.dev/docs/custom-storefronts/hydrogen/debugging/subrequest-profiler |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hydrogen introduces a virtual route (unstable) to debug server-side network request. (Available now with
@2023.7.7
version)This tool will capture all storefront api requests and cache requests and display it in a timeline flame chart.
How to use
Make sure your project is at the required package versions
Update your server.ts so that it also passes in the
waitUntil
andenv
.const handleRequest = createRequestHandler({ build: remixBuild, mode: process.env.NODE_ENV, + getLoadContext: () => ({session, storefront, env, waitUntil}), });
If you are using typescript, make sure to update
remix.env.d.ts
Run
npm run dev
and you should see terminal log information about a new virtual route that you can view server-side network requests at http://localhost:3000/debug-networkOpen http://localhost:3000/debug-network in a tab and your app another tab. When you navigate around your app, you should see server network requests being logged in the debug-network tab
Chart legend & terminologies
MISS
- server will make a fetch request and make a PUT request for the result.HIT
- server will use the response stored in cache.STALE
- server will use the response store in cache and also make a new fetch request to get fresh data to put in cache.PUT
- server will store the result into cache.Problem
One of the main benefits of Hydrogen is that developers can construct a page with multiple api calls. However, there is no convenient way to know if a page is being implemented poorly.
For example, request waterfall. Unknowingly, developers can create request waterfalls when they don’t need to.
Where a simple fix to this issue is to fix the code with a
Promise.all
.Known limitations
fetch
requests - you can work around this by wrappingfetch
withcreateWithCache
Feedbacks
Give us feedbacks and let us know what would you like to see in this debug tool. Some thoughts in brewing from the Hydrogen team:
Gathered feedbacks from elsewhere
Beta Was this translation helpful? Give feedback.
All reactions