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

onPostBuild Error without details? #91

Open
jasonbiondo opened this issue Aug 28, 2020 · 11 comments
Open

onPostBuild Error without details? #91

jasonbiondo opened this issue Aug 28, 2020 · 11 comments

Comments

@jasonbiondo
Copy link

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"
			}
		}
	]
}
@Haroenv
Copy link
Contributor

Haroenv commented Aug 31, 2020

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?

@dorelljames
Copy link

I made the same mistake. I used objectId instead of objectID which it should be. Make sure to notice it's case sensitive.

@Haroenv
Copy link
Contributor

Haroenv commented Sep 8, 2020

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...

@dorelljames
Copy link

dorelljames commented Sep 9, 2020

This below is an example of a build that fails.

image

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.

image

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.

@Haroenv
Copy link
Contributor

Haroenv commented Sep 9, 2020

Thanks @dorelljames. What happens if you change this line to throw new Error?

return report.panic(
`failed to index to Algolia. Argument matchFields has to be an array of strings`
);

@dorelljames
Copy link

Here goes:

image

Output:

image

@dorelljames
Copy link

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

@Haroenv
Copy link
Contributor

Haroenv commented Sep 9, 2020

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?

@dorelljames
Copy link

I think so, yes. Do you mean I create an issue at Gatsby for this matter?

@Haroenv
Copy link
Contributor

Haroenv commented Sep 10, 2020

Yes, please @dorelljames :)

@dorelljames
Copy link

Alright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants