Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Unable to build because of an image fetching / caching error #162

Open
sreucherand opened this issue Mar 15, 2020 · 11 comments
Open

Unable to build because of an image fetching / caching error #162

sreucherand opened this issue Mar 15, 2020 · 11 comments

Comments

@sreucherand
Copy link

Hello!

I'm experiencing a bug using this plugin. Seems to be related to the image caching process.
It happens when building. But only after having cleaned the cache when developing (it works on second run). First yarn start fails then yarn start again and it works.

Here is the error that I'm getting:

ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unexpected error value: "failed to process https://images.prismic.io/issue-03152020/59a58991-59d6-4846-8a67-4306459d5248_original.jpg?auto=compress,format&rect=0,0,1820,2275&w=1820&h=2275\nError: ENOENT: no such file or directory, open '/Users/*****/issue-03152020/.cache/caches/gatsby-source-prismic-graphql/tmp-c09596de258a31bc721c83493efba974.jpg'"

I replicated the bug on a fresh install for you to reproduce: https://github.com/sreucherand/issue-03152020

@andyto
Copy link
Contributor

andyto commented Mar 16, 2020

I am suspecting something is wrong on Prismic's end. I tried to republish the assets in Primsic and it managed to get past occasionally.

@andyto
Copy link
Contributor

andyto commented Mar 18, 2020

I discovered that as long as there is the folder .cache/caches/gatsby-source-prismic-graphql, there will be no error. When the folder is not present, it seems to have a problem creating this folder, thus the above error will happen. It can be solved by creating the folder manually.

In a local development environment, we can create the folder manually, but would be impossible when deployed in netlify for example. Hope this will be fixed soon.

@dphoursa
Copy link

dphoursa commented Mar 18, 2020

@andyto You can create the folder on the fly by placing the following code in gatsby-node.js (this will work for netlify):

var fs = require('fs');
var dir = "./.cache/caches/gatsby-source-prismic-graphql"

exports.onPreBootstrap = () => {
    if (!fs.existsSync(dir)){
        fs.mkdirSync(dir);
    } 
 }

@sreucherand
Copy link
Author

Good catch all!
I found a working fix actually. In gatsby-node.ts, createResolvers should be passing its argument getCache along to createRemoteFileNode as such:

exports.createResolvers = ({ cache, getCache, [...] }) => {
  [...]
  return createRemoteFileNode({
    [...],
    cache,
    getCache,
    [...]
  });
}

I have not investigated more on this. Might do it later and follow up with a PR.

createRemoteFileNode ts types have been updated in version 2.1.55 to allow getCache (see. gatsbyjs/gatsby#22090)

@elias-thok
Copy link

elias-thok commented Mar 23, 2020

I have the same issue. Cost me hours and hours.
Also, if I strip all the imageSharp parts off the graphql-query, the build works and creates .cache/caches/gatsby-source-prismic-graphql. If I then add the imageSharp parts again, the build works, until the next gatsby clean.

@dphoursa your hack works but I hope that's only temporary.

Edit:
Also, I'm having random graphql errors while I run gatsby develop. Sometimes the site crashes with some imageSharp fragments being undefined all of a sudden, even if no image-related code has been changed. Restarting the process often gets rid of it. Could that be related in any way?

@dphoursa
Copy link

@elias-thok Very strange. Are you following the new plugin config of the latest release. Is the name of your image attribute in prismic matches sharpKeys?

@Jdruwe
Copy link

Jdruwe commented Mar 26, 2020

I have the same issue. Unexpected error value: "failed to process https://images.prismic.io/jeroendruwe/cced738b-fa9f-4b84-9d5f-4b4a03ce42f7_frituur.png?auto=compress,format\nError: ENOENT: no such file or directory, open '/Users/jdruwe/Work/freelance/jeroendruwe/.cache/caches/gatsby-source-prismic-graphql/tmp-32ccaf04c2df563b22d46b86a5621c90.png'" Due to imageSharp { in my query

@madeleineostoja
Copy link
Contributor

Just wanted to chime in to say that I can confirm this is a regression in the latest version of the source — I have 2 projects where I changed nothing but upgraded this package and saw this error. The monkeypatch from @dphoursa works well for now.

@codingwithchris
Copy link

codingwithchris commented Apr 26, 2020

I have the exact same issue as described by multiple others above. When trying to query any Sharp image field without an existing ./.cache/caches/gatsby-source-prismic-graphql directory, I get an error similar to:

UNHANDLED REJECTION ENOENT: no such file or directory, open '${mypath}/.cache/caches/gatsby-source-prismic-graphql/${queriedImage}.jpg'

I can also confirm that the on-the-fly folder creation patch in gatsby-node.js suggested above by @dphoursa is working for me. Hoping we can get this fixed for real soon. 🤞

@laradevitt
Copy link

Also ran into this problem. Confirming either rolling back to 3.4.1-alpha.0 or using above-mentioned workaround in gatsby-node.js resolves the error for now. Thanks!

@ptrkvsky
Copy link

ptrkvsky commented May 27, 2020

var fs = require("fs")
var dir = "./.cache/caches/gatsby-source-prismic-graphql"

exports.onPreBootstrap = () => {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  }
}

Wordked for me thanks

codingwithchris added a commit to the-nerve/nerve.web that referenced this issue Jun 12, 2020
- Migrating away from gatsby-source-prismic-graphql due to poor support and continued unadressed stability issues like:

birkir/gatsby-source-prismic-graphql#217

birkir/gatsby-source-prismic-graphql#77

birkir/gatsby-source-prismic-graphql#162
codingwithchris added a commit to the-nerve/nerve.web that referenced this issue Jun 12, 2020
* Begin Implementing SEO on Show Pages

* Build Re-useable Config Context

* Wrap Application in Config Context

* Use New Config Context Instead of Direct Static Query

* Create Simpler Method for Accessing Context in Our Application

* Add Props Validation for Schemas

* Move Fragments to GraphQL Root

* Add Next Season Variable To Context

* Remove Un-needed Index

* Improve Destructuring of UseConfig Returned Data

* Begin Reorganizing/ Rebuilding Schemas

* Update Component To Get Gatsby Compiling

* Begin Rebuilding SEO Schema Component Structure

* Convert Schema to Typescript

* Reorg SEO & New ESLint Configs Project for Project

* Remove Errant “S”

* Implement Zeit Now & Update All Dependencies

* Re-lint All Project FIles

* Remove Deprecated NOW Properties

* Remove References to SEO — Temp

* Prep For Ticket Receipt Email

* Migreate Back to Netlify & Remove API Routes

* Update Dependencies

* Update Readme with Nerve Theatre Data

* Clean Up Global Context

* Fix File Import Case

* Resolve GraphQL Dependency Issue + Update Dependencies

Temporarily resolve an issue with `gatsby-source-graphql-universal` dependency:
birkir/gatsby-source-graphql-universal#14

* Update Netlify Config with Proper Redirect Value Type

* Improve Git Ignore Layout

* Temporarily Resolve Broken Functionality

* Update Snipcart to 3.0.11

* Remove Duplicate Plugins

* Integrate Ascend ESLint Config

* Remove Node Engines

* Continue Typescript Migration & App Refactor + Move to CSS Variables

* Continue Massive Refactor

* Add Keys to SSR List items

* Remove Invalid Theme Prop

* Update Config Query Name

* Finish Converting Legacy Components to Typescript

* Temp Add Typescript Rule

* Add Return Types for Site Config Query

* Remove Slices from Season Type

* Begin Building Link Map

* Build Out Super-Dope Link Map

Give us direct access to all site links/pages/shows/seasons etc. Can you feel the power?

* Remove All Seasons URL from Node

* Set Up Proper Link Map Fallbacks

* Temporarily Fix Issue with `gatsby-source-prismic-graphql` Plugin

birkir/gatsby-source-prismic-graphql#162

* Refactor Query, Type, & Component Structure

* Build Poster Grid & Show Poster Component

* Improve Show Poster Stylings

* Update Packages To Latest

* Completey Convert Codebase to better Gatsby Source Prismic

- Migrating away from gatsby-source-prismic-graphql due to poor support and continued unadressed stability issues like:

birkir/gatsby-source-prismic-graphql#217

birkir/gatsby-source-prismic-graphql#77

birkir/gatsby-source-prismic-graphql#162

* Upgrade to Snipcart 3.0.15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants