Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby v5: Every Static Query loads on every page even when not required #38349

Open
2 tasks done
dkyuho opened this issue Jul 7, 2023 · 0 comments
Open
2 tasks done
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@dkyuho
Copy link

dkyuho commented Jul 7, 2023

Preliminary Checks

Description

  • All pages are fetching all static queries, even the ones that are not being used in our monorepo Gatsby v5 project.
  • This behaviour started from Gatsby v5.0.0 and is still happening on the latest release v5.11.0
  • The last version with properly loaded static queries was on v4.24.0

Reproduction Link

https://github.com/dkyuho/gatsby-monorepo-sandbox

Steps to Reproduce

Gatsby v5.11.0
  1. Clone this repo and run yarn to install all the packages
  2. Run yarn prod to start production server
  3. Inspect the network tab to see that all static queries are being fetched for each page
  4. Navigate to http://localhost:9000/_report.html to see the Perf Report
Gatsby v4.24.0
  1. To see the static queries load properly in Gatsby v4 change to the branch test-gatsby-v4
  2. Run yarn clean && yarn && yarn prod to restart the server.
  3. If this fails delete node_modules and try again
  4. Inspect the network tab or the perf report with v4 to see each page only fetches static queries that are being used by the page

Expected Result

Only the static queries that are being used on the page should be fetched.(Gatsby v4.24.0)

Size of requests

Page Static Queries Total
/ 0 189 b
/404.html 0 195 b
/404 0 192 b
/locations 2.16 kb 2.36 kb
/privacy 2.66 kb 2.87 kb
/teams 1.41 kb 1.61 kb
/testimonials 1.03 kb 1.24 kb

Gatsby sandbox v4 perf

Actual Result

All static queries are being fetched, regardless of whether they are used or not (Gatsby v5.11.0).

Size of requests

Page Static Queries Total
/ 7.26 kb 7.49 kb
/404.html 7.26 kb 7.5 kb
/404 7.26 kb 7.49 kb
/locations 7.26 kb 7.5kb
/privacy 7.26 kb 7.5 kb
/teams 7.26 kb 7.49 kb
/testimonials 7.26 kb 7.5 kb

Gatsby sandbox v5 perf

Environment

System:
    OS: macOS 13.0.1
    CPU: (8) arm64 Apple M1
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 20.0.0 - ~/.nvm/versions/node/v20.0.0/bin/node
    Yarn: 1.22.10 - /opt/homebrew/bin/yarn
    npm: 9.6.4 - ~/.nvm/versions/node/v20.0.0/bin/npm
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 16.1

Config Flags

 flags: {
    DEV_SSR: false,
  }
@dkyuho dkyuho added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 7, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

1 participant