This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
fix: useFetch
perf is significantly worse than useAsync
Β #359
Closed
Description
π The bug
When using useFetch
, TTFB is ~250-300ms on an almost blank page.
Replacing the call with useAsync
yields a significantly lower TTFB of ~30ms
π οΈ To reproduce
Steps to reproduce the behavior:
Go to https://github.com/manniL/nuxt-capi-usefetch-overhead and follow the README:
- Install deps via
yarn
- Launch the application in dev mode via
yarn dev
- Go to http://localhost:3000/async and http://localhost:3000/fetch in new tabs
- See that the TTFB is roughly a magnitude different
To ensure it is not caused by underlying fetch
:
- Go to Go to http://localhost:3000/async-o and http://localhost:3000/fetch-o in new tabs. These are options-api "equivalents"
- See that TTFB is roughly the same
The same scenario can be observed in production as well.
π Expected behaviour
Having both helpers yielding roughly the same TTFB given the same use case
UPDATE: The Nuxt 3 useAsyncData
implementation does not have perf issues (at the time of writing π).
UPDATE2: Seems like it is the callFetches
function that causes the perf degredation