Site name: https://trusting-kepler-bd1fc6.netlify.app
Error: TypeError: Cannot read properties of undefined (reading "edges")
Site builds locally, but not on Netlify. Error comes from querying site for Algolia search, using gatsby-plugin-algolia
.
For context, I’m following this guide, changing the query to match my site. The query runs just fine on graphql and when building locally so I don’t know why it’s not working in Netlify. Everything else is the same.
Deploy log:
8:18:26 PM: build-image version: 3ffff9df3d5419545acc1b673a54de348174406d (focal)
8:18:26 PM: buildbot version: 228d4ef7b03dfc60f183d3edd500451c6a4cc157
8:18:26 PM: Fetching cached dependencies
8:18:26 PM: Starting to download cache of 839.2MB
8:18:39 PM: Finished downloading cache in 12.366s
8:18:39 PM: Starting to extract cache
8:18:42 PM: Finished extracting cache in 2.948s
8:18:42 PM: Finished fetching cache in 15.417s
8:18:42 PM: Starting to prepare the repo for build
8:18:42 PM: Preparing Git Reference refs/heads/master
8:18:45 PM: Starting to install dependencies
8:18:45 PM: Python version set to 3.8
8:18:45 PM: Attempting Ruby version 2.7.2, read from environment
8:18:45 PM: Using Ruby version 2.7.2
8:18:46 PM: Started restoring cached go cache
8:18:46 PM: Finished restoring cached go cache
8:18:47 PM: go version go1.19.13 linux/amd64
8:18:47 PM: Using PHP version 8.0
8:18:48 PM: Started restoring cached Node.js version
8:18:49 PM: Finished restoring cached Node.js version
8:18:49 PM: Downloading and installing node v18.19.0...
8:18:49 PM: Downloading https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.xz...
8:18:50 PM: Computing checksum with sha256sum
8:18:50 PM: Checksums matched!
8:18:52 PM: Now using node v18.19.0 (npm v10.2.3)
8:18:52 PM: Enabling Node.js Corepack
8:18:52 PM: Started restoring cached build plugins
8:18:52 PM: Finished restoring cached build plugins
8:18:52 PM: Started restoring cached corepack dependencies
8:18:52 PM: Finished restoring cached corepack dependencies
8:18:52 PM: No npm workspaces detected
8:18:52 PM: Started restoring cached node modules
8:18:52 PM: Finished restoring cached node modules
8:18:52 PM: Installing npm packages using npm version 10.2.3
8:18:52 PM: npm WARN using --force Recommended protections disabled.
8:18:56 PM: npm WARN ERESOLVE overriding peer dependency
8:18:56 PM: npm WARN While resolving: gatsby-plugin-mdx@5.12.3
8:18:56 PM: npm WARN Found: @mdx-js/react@3.0.0
8:18:56 PM: npm WARN node_modules/@mdx-js/react
8:18:56 PM: npm WARN @mdx-js/react@"^3.0.0" from the root project
8:18:56 PM: npm WARN
8:18:56 PM: npm WARN Could not resolve dependency:
8:18:56 PM: npm WARN peer @mdx-js/react@"^2.0.0" from gatsby-plugin-mdx@5.12.3
8:18:56 PM: npm WARN node_modules/gatsby-plugin-mdx
8:18:56 PM: npm WARN gatsby-plugin-mdx@"^5.12.3" from the root project
8:18:56 PM: npm WARN
8:18:56 PM: npm WARN Conflicting peer dependency: @mdx-js/react@2.3.0
8:18:56 PM: npm WARN node_modules/@mdx-js/react
8:18:56 PM: npm WARN peer @mdx-js/react@"^2.0.0" from gatsby-plugin-mdx@5.12.3
8:18:56 PM: npm WARN node_modules/gatsby-plugin-mdx
8:18:56 PM: npm WARN gatsby-plugin-mdx@"^5.12.3" from the root project
8:18:56 PM: npm WARN ERESOLVE overriding peer dependency
8:18:56 PM: npm WARN While resolving: react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825
8:18:56 PM: npm WARN Found: react@18.2.0
8:18:56 PM: npm WARN node_modules/react
8:18:56 PM: npm WARN react@"^18.2.0" from the root project
8:18:56 PM: npm WARN 14 more (@gatsbyjs/reach-router, @mdx-js/react, gatsby, ...)
8:18:56 PM: npm WARN
8:18:56 PM: npm WARN Could not resolve dependency:
8:18:56 PM: npm WARN peer react@"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825
8:18:56 PM: npm WARN node_modules/react-server-dom-webpack
8:18:56 PM: npm WARN react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from gatsby@5.12.4
8:18:56 PM: npm WARN node_modules/gatsby
8:18:56 PM: npm WARN
8:18:56 PM: npm WARN Conflicting peer dependency: react@0.0.0-experimental-c8b778b7f-20220825
8:18:56 PM: npm WARN node_modules/react
8:18:56 PM: npm WARN peer react@"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825
8:18:56 PM: npm WARN node_modules/react-server-dom-webpack
8:18:56 PM: npm WARN react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from gatsby@5.12.4
8:18:56 PM: npm WARN node_modules/gatsby
8:18:59 PM: npm WARN deprecated @types/keyv@4.2.0: This is a stub types definition. keyv provides its own type definitions, so you do not need this installed.
8:18:59 PM: npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
8:19:10 PM: added 160 packages, removed 251 packages, changed 331 packages, and audited 1594 packages in 17s
8:19:10 PM: 354 packages are looking for funding
8:19:10 PM: run `npm fund` for details
8:19:10 PM: 27 vulnerabilities (21 moderate, 5 high, 1 critical)
8:19:10 PM: To address issues that do not require attention, run:
8:19:10 PM: npm audit fix
8:19:10 PM: To address all issues (including breaking changes), run:
8:19:10 PM: npm audit fix --force
8:19:10 PM: Run `npm audit` for details.
8:19:10 PM: npm packages installed
8:19:10 PM: Successfully installed dependencies
8:19:10 PM: Starting build script
8:19:11 PM: Detected 1 framework(s)
8:19:11 PM: "gatsby" at version "5.12.4"
8:19:11 PM: Section completed: initializing
8:19:13 PM:
8:19:13 PM: Netlify Build
8:19:13 PM: ────────────────────────────────────────────────────────────────
8:19:13 PM:
8:19:13 PM: ❯ Version
8:19:13 PM: @netlify/build 29.29.4
8:19:13 PM:
8:19:13 PM: ❯ Flags
8:19:13 PM: baseRelDir: true
8:19:13 PM: buildId: 656e887166409e00092b4e69
8:19:13 PM: deployId: 656e887166409e00092b4e6b
8:19:13 PM:
8:19:13 PM: ❯ Current directory
8:19:13 PM: /opt/build/repo
8:19:13 PM:
8:19:13 PM: ❯ Config file
8:19:13 PM: No config file was defined: using default values.
8:19:13 PM:
8:19:13 PM: ❯ Context
8:19:13 PM: production
8:19:13 PM:
8:19:13 PM: ❯ Installing plugins
8:19:13 PM: - @netlify/plugin-gatsby@3.8.0
8:19:15 PM:
8:19:15 PM: ❯ Loading plugins
8:19:15 PM: - @netlify/plugin-gatsby@3.8.0 from Netlify app
8:19:16 PM:
8:19:16 PM: @netlify/plugin-gatsby (onPreBuild event)
8:19:16 PM: ────────────────────────────────────────────────────────────────
8:19:16 PM:
8:19:16 PM: Skipping @netlify/plugin-gatsby work, because used Gatsby version supports adapters.
8:19:16 PM:
8:19:16 PM: (@netlify/plugin-gatsby onPreBuild completed in 53ms)
8:19:16 PM:
8:19:16 PM: Build command from Netlify app
8:19:16 PM: ────────────────────────────────────────────────────────────────
8:19:16 PM:
8:19:16 PM: $ gatsby build
8:19:18 PM: success compile gatsby files - 0.687s
8:19:18 PM: success load gatsby config - 0.029s
8:19:20 PM: success Installing Netlify adapter (gatsby-adapter-netlify@^1.0.0-alpha) - 2.253s
8:19:20 PM: info If you plan on staying on this deployment platform, consider installing gatsby-adapter-netlify as a dependency in your project. This will give you faster and more robust installs.
8:19:20 PM: info Using gatsby-adapter-netlify adapter
8:19:22 PM: info [gatsby-adapter-netlify] Found a Gatsby cache. We"re about to go FAST. ⚡
success load plugins - 0.415s
8:19:22 PM: success onPreInit - 0.004s
8:19:22 PM: success delete worker cache from previous builds - 0.001s
8:19:22 PM: info One or more of your plugins have changed since the last time you ran Gatsby. As
8:19:22 PM: a precaution, we"re deleting your site"s cache to ensure there"s no stale data.
success initialize cache - 0.064s
8:19:22 PM: success copy gatsby files - 0.086s
8:19:23 PM: success Compiling Gatsby Functions - 0.160s
8:19:23 PM: success onPreBootstrap - 0.168s
8:19:23 PM: success createSchemaCustomization - 0.004s
8:19:32 PM: success Clean up stale nodes - 0.185s - 0/0 0.00/s
8:19:32 PM: success Checking for changed pages - 0.000s
8:19:32 PM: success source and transform nodes - 8.989s
8:19:33 PM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
8:19:33 PM: success building schema - 1.419s
8:19:34 PM: success createPages - 1.269s
8:19:34 PM: success createPagesStatefully - 0.053s
8:19:34 PM: info Total nodes: 877, SitePage nodes: 136 (use --verbose for breakdown)
8:19:34 PM: success Checking for changed pages - 0.000s
8:19:34 PM: success Cleaning up stale page-data - 0.002s
8:19:34 PM: success onPreExtractQueries - 0.000s
8:19:37 PM: success extract queries from components - 2.426s
8:19:37 PM: success write out redirect data - 0.000s
8:19:37 PM: success Build manifest and related icons - 0.154s
8:19:37 PM: success onPostBootstrap - 0.156s
8:19:37 PM: info bootstrap finished - 21.236s
8:19:37 PM: success write out requires - 0.004s
8:19:57 PM: success Building production JavaScript and CSS bundles - 19.905s
8:20:14 PM: success Building HTML renderer - 17.004s
8:20:14 PM: success Execute page configs - 0.038s
8:20:14 PM: success Caching Webpack compilations - 0.000s
8:20:15 PM: success run queries in workers - 1.297s - 143/143 110.22/s
8:20:15 PM: success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 28.775s - 1/1 0.03/s
8:20:15 PM: success Merge worker state - 0.003s
8:20:15 PM: success Rewriting compilation hashes - 0.001s
8:20:15 PM: success Writing page-data.json and slice-data.json files to public directory - 0.065s - 136/136 2088.42/s
8:20:24 PM: warning Icon " sketch" doesn"t exist.
warning Icon " close-outline" doesn"t exist.
warning Icon "cog" doesn"t exist.
warning Icon "gallery" doesn"t exist.
warning Icon "gallery" doesn"t exist.
warning Icon "timeline" doesn"t exist.
warning Icon "timeline" doesn"t exist.
warning Icon " sketch" doesn"t exist.
warning Icon " close-outline" doesn"t exist.
success Building static HTML for pages - 7.210s - 136/136 18.86/s
8:20:24 PM: info There are no new or changed slice html files to build.
8:20:25 PM: success stitching slices - 0.353s
8:20:25 PM: success Delete previous page data - 0.001s
8:20:27 PM: error failed to index to Algolia Cannot read properties of undefined (reading "edges")
8:20:27 PM:
8:20:27 PM:
8:20:27 PM: TypeError: Cannot read properties of undefined (reading "edges")
8:20:27 PM:
8:20:27 PM: - algolia-queries.js:32 transformer
8:20:27 PM: /opt/build/repo/src/utils/algolia-queries.js:32:41
8:20:27 PM:
8:20:27 PM: - gatsby-node.js:434 getObjectsMapByQuery
8:20:27 PM: [repo]/[gatsby-plugin-algolia]/gatsby-node.js:434:26
8:20:27 PM:
8:20:27 PM: - async Promise.all
8:20:27 PM:
8:20:27 PM: - gatsby-node.js:224 runIndexQueries
8:20:27 PM: [repo]/[gatsby-plugin-algolia]/gatsby-node.js:224:29
8:20:27 PM:
8:20:27 PM: - async Promise.all
8:20:27 PM:
8:20:27 PM: - gatsby-node.js:157 Object.exports.onPostBuild
8:20:27 PM: [repo]/[gatsby-plugin-algolia]/gatsby-node.js:157:5
8:20:27 PM:
8:20:27 PM: - api-runner-node.js:509 runAPI
8:20:27 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:509:16
8:20:27 PM:
8:20:27 PM:
8:20:27 PM: not finished onPostBuild - 2.342s
8:20:27 PM: failed index to Algolia - 2.294s - Running 1 query for index Help...
8:20:28 PM:
8:20:28 PM: "build.command" failed
8:20:28 PM: ────────────────────────────────────────────────────────────────
8:20:28 PM:
8:20:28 PM: Error message
8:20:28 PM: Command failed with exit code 1: gatsby build
8:20:28 PM:
8:20:28 PM: Error location
8:20:28 PM: In Build command from Netlify app:
8:20:28 PM: gatsby build
8:20:28 PM:
8:20:28 PM: Resolved config
8:20:28 PM: build:
8:20:28 PM: command: gatsby build
8:20:28 PM: commandOrigin: ui
8:20:28 PM: environment:
8:20:28 PM: - ALGOLIA_ADMIN_KEY
8:20:28 PM: - ALGOLIA_APP_ID
8:20:28 PM: - ALGOLIA_SEARCH_KEY
8:20:28 PM: - NPM_FLAGS
8:20:28 PM: publish: /opt/build/repo/public
8:20:28 PM: publishOrigin: ui
8:20:28 PM: plugins:
8:20:28 PM: - inputs: {}
8:20:28 PM: origin: ui
8:20:28 PM: package: "@netlify/plugin-gatsby"
8:20:28 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:20:28 PM: Failing build: Failed to build site
8:20:29 PM: Finished processing build request in 2m2.415s
8:20:28 PM: Failed during stage "building site": Build script returned non-zero exit code: 2