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

sourcebit-nextjs-cache.json Not Found #7

Open
slavakurilyak opened this issue Jan 28, 2021 · 4 comments
Open

sourcebit-nextjs-cache.json Not Found #7

slavakurilyak opened this issue Jan 28, 2021 · 4 comments

Comments

@slavakurilyak
Copy link

I am running Stackbit v0.3.44, using Next.js as a web framework and Contentful as a CMS.

When I try to deploy, Netlify log shows me:

2:55:04 PM: Build ready to start
2:55:07 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
2:55:07 PM: build-image tag: v3.6.1
2:55:07 PM: buildbot version: 44655717ddf0e7bd7f856f5b1154254de54b1d80
2:55:07 PM: Fetching cached dependencies
2:55:07 PM: Starting to download cache of 100.4MB
2:55:08 PM: Finished downloading cache in 1.103787039s
2:55:08 PM: Starting to extract cache
2:55:13 PM: Finished extracting cache in 4.426850255s
2:55:13 PM: Finished fetching cache in 5.634974494s
2:55:13 PM: Starting to prepare the repo for build
2:55:13 PM: Preparing Git Reference refs/heads/master
2:55:16 PM: Starting build script
2:55:16 PM: Installing dependencies
2:55:16 PM: Python version set to 2.7
2:55:17 PM: Started restoring cached node version
2:55:19 PM: Finished restoring cached node version
2:55:20 PM: v12.18.0 is already installed.
2:55:21 PM: Now using node v12.18.0 (npm v6.14.4)
2:55:21 PM: Started restoring cached build plugins
2:55:21 PM: Finished restoring cached build plugins
2:55:21 PM: Attempting ruby version 2.7.1, read from environment
2:55:23 PM: Using ruby version 2.7.1
2:55:23 PM: Using PHP version 5.6
2:55:23 PM: Started restoring cached node modules
2:55:23 PM: Finished restoring cached node modules
2:55:24 PM: Installing NPM modules using NPM version 6.14.4
2:55:36 PM: npm WARN [email protected] No repository field.
2:55:36 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack/node_modules/fsevents):
2:55:36 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:55:36 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
2:55:36 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:55:36 PM: added 39 packages from 18 contributors, removed 38 packages, updated 159 packages and audited 961 packages in 11.126s
2:55:36 PM: 40 packages are looking for funding
2:55:36 PM:   run `npm fund` for details
2:55:36 PM: found 5 vulnerabilities (2 low, 3 high)
2:55:36 PM:   run `npm audit fix` to fix them, or `npm audit` for details
2:55:36 PM: NPM modules installed
2:55:37 PM: Started restoring cached go cache
2:55:37 PM: Finished restoring cached go cache
2:55:37 PM: go version go1.14.4 linux/amd64
2:55:37 PM: go version go1.14.4 linux/amd64
2:55:37 PM: Installing missing commands
2:55:37 PM: Verify run directory
2:55:39 PM: ​
2:55:39 PM: ────────────────────────────────────────────────────────────────
2:55:39 PM:   Netlify Build                                                 
2:55:39 PM: ────────────────────────────────────────────────────────────────
2:55:39 PM: ​
2:55:39 PM: ❯ Version
2:55:39 PM:   @netlify/build 8.3.0
2:55:39 PM: ​
2:55:39 PM: ❯ Flags
2:55:39 PM:   deployId: 601340c85ac25d0bd9804cf2
2:55:39 PM:   mode: buildbot
2:55:39 PM: ​
2:55:39 PM: ❯ Current directory
2:55:39 PM:   /opt/build/repo
2:55:39 PM: ​
2:55:39 PM: ❯ Config file
2:55:39 PM:   /opt/build/repo/netlify.toml
2:55:39 PM: ​
2:55:39 PM: ❯ Context
2:55:39 PM:   production
2:55:39 PM: ​
2:55:39 PM: ────────────────────────────────────────────────────────────────
2:55:39 PM:   1. build.command from netlify.toml                            
2:55:39 PM: ────────────────────────────────────────────────────────────────
2:55:39 PM: ​
2:55:39 PM: $ ./stackbit-build.sh
2:55:39 PM: echo "stackbit-build.sh: start build"
2:55:39 PM: stackbit-build.sh: start build
2:55:39 PM: # build site
2:55:39 PM: npm run build
2:55:39 PM: > [email protected] build /opt/build/repo
2:55:39 PM: > next build && next export
2:55:40 PM: Browserslist: caniuse-lite is outdated. Please run:
2:55:40 PM: npx browserslist@latest --update-db
2:55:41 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
2:55:41 PM: info  - Creating an optimized production build...
2:55:51 PM: ✖ An error occurred when processing the plugins: Cannot read property 'fields' of null.
2:56:13 PM: info  - Compiled successfully
2:56:13 PM: info  - Collecting page data...
2:56:14 PM: Page [...slug].js getStaticPaths
2:56:14 PM: SourcebitDataClient.getStaticPaths
2:56:14 PM: SourcebitDataClient.getData
2:56:14 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #1
2:56:14 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #2
2:56:15 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #3
2:56:15 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #4
2:56:16 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #5
2:56:16 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #6
2:56:17 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #7
2:56:17 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #8
2:56:18 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #9
2:56:18 PM: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found, waiting 500ms and retry #10
2:56:19 PM: > Build error occurred
2:56:19 PM: Error: SourcebitDataClient.getData, cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' was not found after 10 retries
2:56:19 PM:     at Timeout.checkPathExists [as _onTimeout] (/opt/build/repo/node_modules/sourcebit-target-next/index.js:362:25) {
2:56:19 PM:   type: 'Error'
2:56:19 PM: }
2:56:19 PM: npm ERR! code ELIFECYCLE
2:56:19 PM: npm ERR! errno 1
2:56:19 PM: npm ERR! [email protected] build: `next build && next export`
2:56:19 PM: npm ERR! Exit status 1
2:56:19 PM: npm ERR!
2:56:19 PM: npm ERR! Failed at the [email protected] build script.
2:56:19 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2:56:19 PM: npm ERR! A complete log of this run can be found in:
2:56:19 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-01-28T22_56_19_292Z-debug.log
2:56:19 PM: ​
2:56:19 PM: ────────────────────────────────────────────────────────────────
2:56:19 PM:   "build.command" failed                                        
2:56:19 PM: ────────────────────────────────────────────────────────────────
2:56:19 PM: ​
2:56:19 PM:   Error message
2:56:19 PM:   Command failed with exit code 1: ./stackbit-build.sh
2:56:19 PM: ​
2:56:19 PM:   Error location
2:56:19 PM:   In build.command from netlify.toml:
2:56:19 PM:   ./stackbit-build.sh
2:56:19 PM: ​
2:56:19 PM:   Resolved config
2:56:19 PM:   build:
2:56:19 PM:     command: ./stackbit-build.sh
2:56:19 PM:     commandOrigin: config
2:56:19 PM:     environment:
2:56:19 PM:       - CONTENTFUL_ACCESS_TOKEN
2:56:19 PM:       - CONTENTFUL_DELIVERY_TOKEN
2:56:19 PM:       - INCOMING_HOOK_BODY
2:56:19 PM:       - INCOMING_HOOK_TITLE
2:56:19 PM:       - INCOMING_HOOK_URL
2:56:19 PM:     publish: /opt/build/repo/out
2:56:19 PM: Caching artifacts
2:56:19 PM: Started saving node modules
2:56:19 PM: Finished saving node modules
2:56:19 PM: Started saving build plugins
2:56:19 PM: Finished saving build plugins
2:56:19 PM: Started saving pip cache
2:56:19 PM: Finished saving pip cache
2:56:19 PM: Started saving emacs cask dependencies
2:56:19 PM: Finished saving emacs cask dependencies
2:56:19 PM: Started saving maven dependencies
2:56:19 PM: Finished saving maven dependencies
2:56:19 PM: Started saving boot dependencies
2:56:19 PM: Finished saving boot dependencies
2:56:19 PM: Started saving rust rustup cache
2:56:19 PM: Finished saving rust rustup cache
2:56:19 PM: Started saving go dependencies
2:56:19 PM: Finished saving go dependencies
2:56:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:56:19 PM: Failing build: Failed to build site
2:56:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
2:56:19 PM: Finished processing build request in 1m12.469001017s

Two issues come up during the deployment:

  1. Cannot read property 'fields' of null.
  2. cache file '/opt/build/repo/.sourcebit-nextjs-cache.json' not found

Thoughts?

@smnh
Copy link
Member

smnh commented Jan 31, 2021

Hi @slavakurilyak

It seems like sourcebit-source-contentful plugin gets an error while fetching data (Cannot read property 'fields' of null). So sourcebit-target-next couldn't save that data in a file and use it.

Which version of sourcebit-source-contentful plugin you are using?
I remember we fixed a similar problem and released a new version 0.6.4

@slavakurilyak
Copy link
Author

@smnh Thanks for your reply!

I was using 0.6.2 which generated at 2021-01-29T06:24:38.534Z by Stackbit 0.3.44.

Consider bumping the Stackbit generator to include this fix and bumping Next.js to v10+ 😉

@rudietuesdays
Copy link

Hi, I'm having a similar issue as well. Using the following versions:

"next": "^12.1.0",
"sourcebit-source-sanity": "^0.4.5",
"sourcebit-target-next": "^0.8.3",

The file .sourcebit-nextjs-cache.json itself is built, but it's totally blank.

Would love any thoughts and guidance you have!

@smnh
Copy link
Member

smnh commented Jul 28, 2022

@rudietuesdays this can be caused by sourcebit-source-sanity misconfiguration, please check that the options for sanity projectid, dataset and token are all correct.

You can also add an empty plugin with console.log statement between sourcebit-source-sanity and sourcebit-target-next to validate that sourcebit-source-sanity actually returns some data.

If there is some data then sourcebit-target-next should store it inside the .sourcebit-nextjs-cache.json file when it runs.

module.exports = {
    plugins: [
        {
            module: require('sourcebit-source-sanity'),
            options: { /* sourcebit-source-sanity options here */ }
        },

        ({ data }) => {
            console.log(JSON.stringify(data, null, 4));
            return data;
        },

        {
            module: require('sourcebit-target-next'),
            options: { /* sourcebit-target-next options here */ }
        }
    ]
};

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