question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createRemoteFileNode failing on contentLength check, but file might be not incomplete at all

See original GitHub issue

Description

I am using the createRemoteFileNode as explained in https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#feeding-remote-images-into-gatsby-image, it takes in my image field, which can be a png, jpg, […] or svg, sourcing from Cloudinary.

Now with the latest gatsby releases my code starts crashing to Failed to download ... after 3 attempts (the INCOMPLETE_RETRY_LIMIT one) and I seem to have narrowed it down to svgs. And even more so: https://github.com/gatsbyjs/gatsby/pull/28547/files#diff-ed27ffe776b2ef7b45a29f65fc4b9b01922de1c85ec42e9a92722b3949110a82R188 failing to match content lengths makes the code crash the download. Now I debugged Cloudinary shipping my svgs gzipped. I’m no expert on content length, but my (not so) wild guess right now is that zipped svg’s are indeed not the same content length as written bytes?

Steps to reproduce

adding a createRemoteFileNode to a remote url. my code (fetching remote images on Strapi uploads via gatsby-source-graphql):

createResolvers({
    STRAPI_UploadFile: {
      imageFile: {
        type: 'File',
        resolve: async (source) => {
          if (!source.url) {
            return null;
          }
          let res;
          try {
            res = await createRemoteFileNode({
              url: source.url,
              store,
              cache,
              createNode,
              createNodeId,
              reporter,
            });
          } catch (err) {
            console.error(`[createResolvers] error in fetching remote image ${source.url} (${source.name}):`, err);
            throw err;
          }
          return res;
        },
      },

Expected result

A file can be checked on incompleteness, including SVGs and zipped files

Actual result

An error is thrown because the file seems to have an incorrect content length. (but the file is downloaded correctly)

Environment

System: OS: macOS 10.15.7 CPU: (8) x64 Intel® Core™ i7-1060NG7 CPU @ 1.20GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.15.1 - /var/folders/gh/yg99pwqj2rngz5wysjcgl8ph0000gn/T/yarn–1610380123259-0.7945398836762099/node Yarn: 1.22.4 - /var/folders/gh/yg99pwqj2rngz5wysjcgl8ph0000gn/T/yarn–1610380123259-0.7945398836762099/yarn npm: 6.14.8 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 87.0.4280.88 Safari: 14.0.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wardpeetcommented, Jan 14, 2021

Hey, thanks for pointing it out. We have a fix in https://github.com/gatsbyjs/gatsby/pull/28913 that will solve this. We’ll publish it in the next patch release. For now you can try the @next tag.

0reactions
ahmadkhalaf1commented, Nov 15, 2022

@wardpeet hi , seems like the fix from the version 2.9.1 is not pushed forward to new versions , can you please confirm ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby Changelog | 5.3.0
In PR #36623 we fixed this behavior and any node changes (either by changing local files or through webhook updates) will be reflected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found