gatsby: vips2png: "unable to write to target" error when generating thumbnails breaks the build

Description

During the build step, this error happens

vipspng: libpng read error vips2png: unable to write to target

Please, could you provide me with a way to debug which image might be breaking vips2png (used by sharp plugin)? We have a thousand of them

The error happens in CircleCI, and it’s difficult to replicate in our local because of x number of reasons.

More context:

info bootstrap finished - 39.546s

warning 
 
 [] 0/96 0.0 s 0% Generating image thumbnailswarning 
                 The requested height "500px" for a resolutions field for
                 the file /home/circleci/project/.cache/caches/gatsby-source-drupal/7f6345e68e32e87cf256a6dbc8a1b279/example.png
                 was larger than the actual image height of 330px!
                 If possible, replace the current image with a larger one.
 [] 0/135 0.0 s 0% Generating image thumbnails [] 0/182 0.0 s 0% Generating image thumbnails [] 0/185 0.0 s 0% Generating image thumbnails [] 1739/1749 34.5 s 99% Downloading remote files [] 1741/1749 34.6 s 99% Downloading remote fileserror There was an error in your GraphQL query:
  
vipspng: libpng read error 
vips2png: unable to write to target

  57 |   langcode
  58 |   title
  59 |   created
  60 |   path {
  61 |     alias
  62 |   }
  63 |   relationships {
  64 |     field_recipe_image {
  65 |       localFile {
  66 |         childImageSharp { 
> 67 |           fixed(height: 500)  
     |           ^
  68 |             ...GatsbyImageSharpFixed_withWebp
  69 |           }
  70 |         }
  71 |       }
  72 |     }
  73 |   }
  74 | }
  75 | 
  76 | query ListingQuery {
  77 |   allNodeProductPage {
 
File path: /home/circleci/project/src/components/Listing.js
Plugin: none

not finished run queries - 3.854s
not finished Generating image thumbnails - 3.828s
 

Steps to reproduce

Sorry, not easy to reproduce, since I’m trying to pinpoint what PNG image is the one that is breaking sharp plugin (specifically, what is breaking vips2png ) It seems it’s an open issue https://github.com/libvips/libvips/issues/1578

Expected result

Build succeeds.

Actual result

Build breaks.

Environment


System:
    OS: macOS Mojave 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.12.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
  Languages:
    Python: 2.7.17 - /usr/local/bin/python
  Browsers:
    Chrome: 83.0.4103.61
    Firefox: 75.0
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.22.3 => 2.22.3
    gatsby-background-image: ^1.1.1 => 1.1.1
    gatsby-image: ^2.4.5 => 2.4.5
    gatsby-plugin-client-side-redirect: ^1.1.0 => 1.1.0
    gatsby-plugin-manifest: ^2.4.8 => 2.4.8
    gatsby-plugin-meta-redirect: ^1.1.1 => 1.1.1
    gatsby-plugin-offline: ^3.2.6 => 3.2.6
    gatsby-plugin-react-helmet: ^3.3.2 => 3.3.2
    gatsby-plugin-sharp: ^2.6.8 => 2.6.8
    gatsby-plugin-styled-components: ^3.3.2 => 3.3.2
    gatsby-source-drupal: ^3.5.7 => 3.5.7
    gatsby-source-filesystem: ^2.3.7 => 2.3.7
    gatsby-transformer-json: ^2.4.3 => 2.4.3
    gatsby-transformer-sharp: ^2.5.3 => 2.5.3
  npmGlobalPackages:
    gatsby-cli: 2.8.18

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 23 (8 by maintainers)

Most upvoted comments

Traced down the root source of the error & catch the error and print out which file is causing the problem https://github.com/gatsbyjs/gatsby/pull/28614

Thanks @ascorbic. It’s happening randomly, some of the builds are green. We are thinking it could be some of the images are huge, 40Mb could error silently. We will try to narrow down the issue.

@dcorb I don’t think it’s the same as that issue. Your first error says vipspng: libpng read error, which means it is almost certainly a broken source image as you first thought. The problem here is that we should fail gracefully, and should at the very least log out which image is causing the error.