Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

fix: useFetch perf is significantly worse than useAsync #359

Closed
manniL opened this issue Feb 3, 2021 · 0 comments Β· Fixed by #362
Closed

fix: useFetch perf is significantly worse than useAsync #359

manniL opened this issue Feb 3, 2021 · 0 comments Β· Fixed by #362
Assignees
Labels
bug Something isn't working

Comments

@manniL
Copy link
Member

manniL commented Feb 3, 2021

πŸ› 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:

  1. Install deps via yarn
  2. Launch the application in dev mode via yarn dev
  3. Go to http://localhost:3000/async and http://localhost:3000/fetch in new tabs
  4. See that the TTFB is roughly a magnitude different

To ensure it is not caused by underlying fetch:

  1. Go to Go to http://localhost:3000/async-o and http://localhost:3000/fetch-o in new tabs. These are options-api "equivalents"
  2. 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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants