GraphQL query "fetch failed" error.
The log provided indicates that the Next.js project is being built and it encounters an error while prerendering the /sitemap.xml page. The error message suggests a "fetch failed" issue, indicating that there might be a problem with a GraphQL query in the /sitemap.xml page component.
[00:27:26.857] Running build in Cleveland, USA (East) – cle1
[00:27:26.911] Cloning github.com/mwan9ilwa/quest (Branch: main, Commit: 4f05106)
[00:27:27.151] Previous build cache not available
[00:27:27.342] Cloning completed: 431.941ms
[00:27:27.696] Running "vercel build"
[00:27:28.153] Vercel CLI 31.2.3
[00:27:28.399] Warning: Detected "engines": { "node": ">=18" } in your package.json that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version
[00:27:28.415] Detected pnpm-lock.yaml version 6 generated by pnpm 8...
[00:27:28.427] Installing dependencies...
[00:27:28.938] Lockfile is up to date, resolution step is skipped
[00:27:28.961] Progress: resolved 1, reused 0, downloaded 0, added 0
[00:27:29.028] Packages: +442
[00:27:29.028] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[00:27:29.381] Packages are hard linked from the content-addressable store to the virtual store.
[00:27:29.381] Content-addressable store is at: /vercel/.local/share/pnpm/store/v3
[00:27:29.381] Virtual store is at: node_modules/.pnpm
[00:27:29.970] Progress: resolved 442, reused 0, downloaded 40, added 36
[00:27:30.972] Progress: resolved 442, reused 0, downloaded 112, added 112
[00:27:31.976] Progress: resolved 442, reused 0, downloaded 226, added 219
[00:27:32.977] Progress: resolved 442, reused 0, downloaded 378, added 372
[00:27:33.977] Progress: resolved 442, reused 0, downloaded 436, added 436
[00:27:34.977] Progress: resolved 442, reused 0, downloaded 438, added 438
[00:27:35.977] Progress: resolved 442, reused 0, downloaded 440, added 440
[00:27:36.978] Progress: resolved 442, reused 0, downloaded 442, added 441
[00:27:37.311] Progress: resolved 442, reused 0, downloaded 442, added 442, done
[00:27:37.503] .../node_modules/@vercel/git-hooks install$ node ./install.js
[00:27:37.558] .../node_modules/@vercel/git-hooks install: △ @vercel/git-hooks: installing base hook to /vercel/path0/.git/hooks
[00:27:37.559] .../node_modules/@vercel/git-hooks install: △ @vercel/git-hooks: hooks installed successfully
[00:27:37.561] .../node_modules/@vercel/git-hooks install: Done
[00:27:37.676]
[00:27:37.676] dependencies:
[00:27:37.676] + @headlessui/react 1.7.15
[00:27:37.676] + @heroicons/react 2.0.18
[00:27:37.676] + clsx 2.0.0
[00:27:37.676] + next 13.4.13-canary.15
[00:27:37.676] + react 18.2.0
[00:27:37.676] + react-dom 18.2.0
[00:27:37.676]
[00:27:37.677] devDependencies:
[00:27:37.677] + @tailwindcss/container-queries 0.1.1
[00:27:37.677] + @tailwindcss/typography 0.5.9
[00:27:37.677] + @types/node 20.4.4
[00:27:37.677] + @types/react 18.2.16
[00:27:37.677] + @types/react-dom 18.2.7
[00:27:37.677] + @vercel/git-hooks 1.0.0
[00:27:37.677] + autoprefixer 10.4.14
[00:27:37.677] + eslint 8.45.0
[00:27:37.677] + eslint-config-next 13.4.12
[00:27:37.677] + eslint-config-prettier 8.8.0
[00:27:37.677] + eslint-plugin-unicorn 48.0.0
[00:27:37.677] + lint-staged 13.2.3
[00:27:37.677] + postcss 8.4.27
[00:27:37.677] + prettier 3.0.1
[00:27:37.677] + prettier-plugin-tailwindcss 0.4.1
[00:27:37.677] + tailwindcss 3.3.3
[00:27:37.677] + typescript 5.1.6
[00:27:37.677]
[00:27:37.691] Done in 9.2s
[00:27:37.731] Detected Next.js version: 13.4.13-canary.15
[00:27:37.737] Running "pnpm run build"
[00:27:38.202]
[00:27:38.202] > @ build /vercel/path0
[00:27:38.203] > next build
[00:27:38.203]
[00:27:38.647] - warn You have enabled experimental feature (serverActions) in next.config.js.
[00:27:38.647] - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
[00:27:38.648]
[00:27:38.660] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[00:27:38.660] This information is used to shape Next.js' roadmap and prioritize features.
[00:27:38.661] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[00:27:38.661] https://nextjs.org/telemetry
[00:27:38.661]
[00:27:38.740] - info Creating an optimized production build...
[00:27:59.308] - info Compiled successfully
[00:27:59.309] - info Skipping linting
[00:27:59.309] - info Checking validity of types...
[00:28:02.680] - info Collecting page data...
[00:28:10.860] - info Generating static pages (0/5)
[00:28:10.921] - info Generating static pages (1/5)
[00:28:10.995] - info Generating static pages (2/5)
[00:28:10.996] - info Generating static pages (3/5)
[00:28:11.043]
[00:28:11.044] Error occurred prerendering page "/sitemap.xml". Read more: https://nextjs.org/docs/messages/prerender-error
[00:28:11.044] {
[00:28:11.044] "status": 500,
[00:28:11.044] "message": "fetch failed",
[00:28:11.044] "query": "\n query getCollections {\n collections(first: 100, sortKey: TITLE) {\n edges {\n node {\n ...collection\n }\n }\n }\n }\n \n fragment collection on Collection {\n handle\n title\n description\n seo {\n ...seo\n }\n updatedAt\n }\n \n fragment seo on SEO {\n description\n title\n }\n\n\n"
[00:28:11.044] }
[00:28:11.144] - info Generating static pages (5/5)
[00:28:11.146]
[00:28:11.147] > Export encountered errors on following paths:
[00:28:11.148] /sitemap.xml/route: /sitemap.xml
[00:28:11.194] ELIFECYCLE Command failed with exit code 1.
[00:28:11.214] Error: Command "pnpm run build" exited with 1
@mwan9ilwa we just merged in some changes yesterday that should add more clarity into what's going wrong. Can you update and see what new information is says or if it works for you now?
Build Failed, below are the errors occurred during vercel deployment.
Command "pnpm run build" exited with 1
07:25:04.053 | Error occurred prerendering page "/sitemap.xml". Read more: https://nextjs.org/docs/messages/prerender-error
ELIFECYCLE Command failed with exit code 1.
07:25:04.223 | Error: Command "pnpm run build" exited with 1
Hi, I've got the same issue on vercel and on the localhost here is the log:|
`git:(main) ✗ npm run dev
dev next dev
-
info Loaded env from /private/var/www/erenza/.env.local
-
warn You have enabled experimental feature (serverActions) in next.config.js.
-
warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
-
ready started server on 0.0.0.0:3000, url: http://localhost:3000 /bin/sh: pnpm: command not found (node:4009) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...to show where the warning was created) -
event compiled client and server successfully in 120 ms (20 modules)
-
wait compiling...
-
event compiled client and server successfully in 93 ms (20 modules)
-
info Loaded env from /private/var/www/erenza/.env.local
-
info Loaded env from /private/var/www/erenza/.env.local (node:4008) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...to show where the warning was created) (node:4012) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time (Usenode --trace-warnings ...to show where the warning was created) -
wait compiling /page (client and server)...
-
event compiled client and server successfully in 1271 ms (1899 modules)
-
error { cause: 'Error: getaddrinfo ENOTFOUND http', status: 500, message: 'fetch failed', query: '\n query getCollectionProducts(\n $handle: String!\n $sortKey: ProductCollectionSortKeys\n $reverse: Boolean\n ) {\n collection(handle: $handle) {\n products(sortKey: $sortKey, reverse: $reverse, first: 100) {\n edges {\n node {\n ...product\n }\n }\n }\n }\n }\n \n fragment product on Product {\n id\n handle\n availableForSale\n title\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n edges {\n node {\n id\n title\n availableForSale\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n }\n }\n }\n featuredImage {\n ...image\n }\n images(first: 20) {\n edges {\n node {\n ...image\n }\n }\n }\n seo {\n ...seo\n }\n tags\n updatedAt\n }\n \n fragment image on Image {\n url\n altText\n width\n height\n }\n\n \n fragment seo on SEO {\n description\n title\n }\n\n\n' }
-
error { cause: 'Error: getaddrinfo ENOTFOUND http', status: 500, message: 'fetch failed', query: '\n query getMenu($handle: String!) {\n menu(handle: $handle) {\n items {\n title\n url\n }\n }\n }\n' }
-
error { cause: 'Error: getaddrinfo ENOTFOUND http', status: 500, message: 'fetch failed', query: '\n query getCollectionProducts(\n $handle: String!\n $sortKey: ProductCollectionSortKeys\n $reverse: Boolean\n ) {\n collection(handle: $handle) {\n products(sortKey: $sortKey, reverse: $reverse, first: 100) {\n edges {\n node {\n ...product\n }\n }\n }\n }\n }\n \n fragment product on Product {\n id\n handle\n availableForSale\n title\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n edges {\n node {\n id\n title\n availableForSale\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n }\n }\n }\n featuredImage {\n ...image\n }\n images(first: 20) {\n edges {\n node {\n ...image\n }\n }\n }\n seo {\n ...seo\n }\n tags\n updatedAt\n }\n \n fragment image on Image {\n url\n altText\n width\n height\n }\n\n \n fragment seo on SEO {\n description\n title\n }\n\n\n' }
-
error { cause: 'Error: getaddrinfo ENOTFOUND http', status: 500, message: 'fetch failed', query: '\n query getMenu($handle: String!) {\n menu(handle: $handle) {\n items {\n title\n url\n }\n }\n }\n' }
-
error [Error: Error: [object Object]] { digest: '2106318912' }
-
error [Error: Error: [object Object]] { digest: '2106318912' }
-
error [Error: Error: [object Object]] { digest: '2106318912' }
-
error [Error: Error: [object Object]] { digest: '2106318912' }
-
wait compiling /favicon.ico/route (client and server)...
-
event compiled successfully in 92 ms (90 modules)
`
@mwan9ilwa there is not enough information in your post for us to help you. If you're using the latest code from main, I'd expect to see an error object with the following properties.
{
"cause": "..."
"status": 500,
"message": "fetch failed",
"query": "..."
}
@szymon-wiatr this tells me something is incorrect with your SHOPIFY_STORE_DOMAIN environment variable. It think's the url if your Shopify store is http. Please double check that it's correct.
@manovotny yes, it was :) now it builds fine. Thanks! btw. do you know what SHOPIFY_REVALIDATION_SECRET is and where I can generate it? I cannot find it in Shopify API docs. @mwan9ilwa maybe you had same issue as mine, I've got sitemap.xml file related log in vercel:
Error occurred prerendering page "/sitemap.xml". Read more: https://nextjs.org/docs/messages/prerender-error
{ "cause": "Error: getaddrinfo ENOTFOUND http", "status": 500, "message": "fetch failed", "query": "\n query getCollections {\n collections(first: 100, sortKey: TITLE) {\n edges {\n node {\n ...collection\n }\n }\n }\n }\n \n fragment collection on Collection {\n handle\n title\n description\n seo {\n ...seo\n }\n updatedAt\n }\n \n fragment seo on SEO {\n description\n title\n }\n\n\n" }
- info Generating static pages (3/5)
- info Generating static pages (5/5)
Export encountered errors on following paths: /sitemap.xml/route: /sitemap.xml ELIFECYCLE Command failed with exit code 1. Error: Command "pnpm run build" exited with 1
and now it works and builds fine :) Thanks again @manovotny
btw. do you know what SHOPIFY_REVALIDATION_SECRET is and where I can generate it? I cannot find it in Shopify API docs.
@szymon-wiatr that's something we added to the template ourselves to secure the communication between Shopify and your app on Vercel. You can read more about it in our Vercel and Shopify guide.
Given this is likely an env var issue, I am going to close this issue. We can reopen it or start a new one if more details signal otherwise.
@mwan9ilwa there is not enough information in your post for us to help you. If you're using the latest code from
main, I'd expect to see an error object with the following properties.{ "cause": "..." "status": 500, "message": "fetch failed", "query": "..." }
Sure, here's the error object with the above properties.
{
"status": 500,
"message": "fetch failed",
"query": "\n query getCollections {\n collections(first: 100, sortKey: TITLE) {\n edges {\n node {\n ...collection\n }\n }\n }\n }\n \n fragment collection on Collection {\n handle\n title\n description\n seo {\n ...seo\n }\n updatedAt\n }\n \n fragment seo on SEO {\n description\n title\n }\n\n\n"
}
info Generating static pages (5/5)
Export encountered errors on following paths: /sitemap.xml/route: /sitemap.xml
@mwan9ilwa since there isn't a cause property on the error object, I don't think you're using the latest code from main. Your code should have this. If it doesn't, please update to the latest and try again.
@mwan9ilwa since there isn't a
causeproperty on the error object, I don't think you're using the latest code frommain. Your code should have this. If it doesn't, please update to the latest and try again.
I recently just updated from the main this morning before I shared that log. I'm up to date with the commits from main.