gatsby-plugin-algolia
gatsby-plugin-algolia copied to clipboard
onPostBuild Error without details?
I'm trying to integrate this plugin, but when I build my project I get the following errors in my terminal. I'm not sure where the error is or what needs to be fixed. Can you help?
success Building static HTML for pages - 1.945s - 597/597 307.00/s
Algolia: 1 queries to index
Algolia: query #1: executing query
⠹ onPostBuild
not finished onPostBuild - 0.266s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `env-cmd -f .env.production gatsby build`
npm ERR! Exit status 1
Here is my gatsby-config:
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`
})
const productsQuery = `{
allShopifyProduct(sort: { fields: [title] }) {
edges {
node {
title
}
}
}
}`
const queries = [
{
query: productsQuery,
transformer: ({ data }) => data.allShopifyProduct.edges
}
]
module.exports = {
siteMetadata: {
title: "My Site"
},
plugins: [
"gatsby-plugin-sass",
"gatsby-transformer-sharp",
"gatsby-plugin-sharp",
{
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
indexName: process.env.ALGOLIA_INDEX_NAME,
queries,
chunksize: 1000,
enablePartialUpdates: true
}
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "pages",
path: "src/pages"
}
},
{
resolve: "gatsby-source-prismic",
options: {
repositoryName: process.env.PRISMIC_REPOSITORY_NAME,
accessToken: process.env.PRISMIC_ACCESS_TOKEN,
schemas: {
simple_page_content: require("./src/schemas/simple_page_content.json"),
privacy_policy: require("./src/schemas/privacy_policy.json"),
homepage_banner: require("./src/schemas/homepage_banner.json")
//header_menu: require('./src/schemas/header_menu.json'),
}
}
},
{
resolve: "gatsby-source-shopify",
options: {
shopName: process.env.SHOPIFY_STORE_NAME,
accessToken: process.env.SHOPIFY_STOREFRONT_API_TOKEN,
includeCollections: ["shop"],
paginationSize: 30,
apiVersion: "2020-07"
}
}
]
}
hmm, this is a duplicate of #89, the error when there's no id
or objectID
in the query doesn't seem to throw correctly.
Can you try editing your node_modules' version of https://github.com/algolia/gatsby-plugin-algolia/blob/master/gatsby-node.js#L109 and see if it gets there? maybe it should be changed to an error?
I made the same mistake. I used objectId
instead of objectID
which it should be. Make sure to notice it's case sensitive.
thanks @dorelljames, can you paste the logs (remove private info) of what that looks like? There's already an error which should be thrown there...
This below is an example of a build that fails.
Notice the last few lines:
Algolia: 1 queries to index
Algolia: query #1: executing query
⠦ onPostBuild
not finished onPostBuild - 1.488s
This below is an example of a build that works.
Notice the last few lines:
Algolia: 1 queries to index
Algolia: query #1: executing query
Algolia: query 0: graphql resulted in 59 records
Algolia: query 0: splitting in 1 jobs
Algolia: query 0: moving copied index to main index
⠹ onPostBuild
info Generated public/sw.js, which will precache 10 files, totaling 501168 bytes.
The following pages will be precached:
/offline-plugin-app-shell-fallback/index.html
success onPostBuild - 3.610s
info Done building in 18.217 sec
After that, it continues to work and generate a service worker file. In my gatsby-config.js
, I have placed gatsby-plugin-offline
at the bottom part. You'll also notice the success
and info
log that indicates it succeeded and done building.
Thanks @dorelljames. What happens if you change this line to throw new Error?
https://github.com/algolia/gatsby-plugin-algolia/blob/983a49e7ec3dda4c057e1791688328bb1cc8e0af/gatsby-node.js#L74-L76
Here goes:
Output:
Perhaps this would help us well:
❯ gatsby -v
Gatsby CLI version: 2.12.65
Gatsby version: 2.24.47
Note: this is the Gatsby version for the site at: /Users/dorelljames/Projects/dorellblog
Hmm, I feel like this is a bug in Gatsby. Can you create a bug there with the reproduction where report.panic
a throw new Error
in onPostBuild doesn't show the message?
I think so, yes. Do you mean I create an issue at Gatsby for this matter?
Yes, please @dorelljames :)
Alright.