Skip to content
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
@TheAlexLichter

Description

@TheAlexLichter

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions