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

[gatsby-source-wordpress] No localFile field on images in ACF fields #2492

Closed
garytokyo opened this issue Oct 17, 2017 · 37 comments
Closed

[gatsby-source-wordpress] No localFile field on images in ACF fields #2492

garytokyo opened this issue Oct 17, 2017 · 37 comments
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@garytokyo
Copy link

I was using the wordpress example site to work out how to use Sharp and got it working fine with allWordpressWpMedia or any wordpress Media query but on ACF it does not work in the same way. localFile just doesn't appear as an option in the graphql schema for ACF image fields. That seems to be the way it is being done in the example.

Example query below:

acf {
  collaboration {
    image {
      url
      localFile {
        id
      }
    }
    copy
  }
}
{
  "errors": [
    {
      "message": "Cannot query field \"localFile\" on type \"image_2\".",
      "locations": [
        {
          "line": 22,
          "column": 11
        }
      ]
    }
  ]
}

I'm wondering if this could be due to the same issue as my previous ticket when ACF fields couldn't be queried if some pages/posts didn't have them.

@KyleAMathews
Copy link
Contributor

It's hard to say without seeing a working example of this problem. Could you create a small site reproducing this problem and push it to Github that we could play with?

FWIW, this is the exact setup on the using-wordpress example site

@garytokyo
Copy link
Author

@KyleAMathews here you go. This is using all the same versions as on my main project but I have just created a shell wordpress install. Just need to install wordpress via composer and point a virtual host at it. I have included the query I ran in the readme

@KyleAMathews
Copy link
Contributor

I don't have composer running on my machine :-) Could you put the wordpress on a free host somewhere?

Also, feel free to take a crack at solving the issue yourself — check out the data in .cache/redux-state.json also if there's any files downloaded to .cache/gatsby-source-filesystem/.

This is where files are downloaded

fileNode = await createRemoteFileNode({

Perhaps ACF has multiple ways of creating file attachments where we're only handling media?

@garytokyo
Copy link
Author

garytokyo commented Oct 19, 2017

@KyleAMathews I haven't really got time to be setting up hosting. I've committed everything to the repo so all you need to do is point a virtual host at it and setup and import database.

It is downloading the media files from acf fields to .cache/gatsby-source-filesystem/ but just doesn't seem to generate a reference to the local file in graphQL so there is no way to use the local image.

Also it seems to be generated correctly in redux-state.json (this is from the demo I put together for you guys):

"97c01a7a-4a9c-5fb4-a5cf-9cd50ae5cc86": {
      "wordpress_id": 20,
      "date": "2017-10-18T10:37:54.000Z",
      "guid": "http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg",
      "modified": "2017-10-18T10:37:58.000Z",
      "slug": "cat",
      "status": "inherit",
      "type": "attachment",
      "link": "http://demowordpressapi.local/about/cat/",
      "title": "cat",
      "comment_status": "open",
      "ping_status": "closed",
      "template": "",
      "meta": [],
      "description": "<p class=\"attachment\"><a href='http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg'><img width=\"300\" height=\"200\" src=\"http://demowordpressapi.local/wp-content/uploads/2017/10/cat-300x200.jpeg\" class=\"attachment-medium size-medium\" alt=\"\" srcset=\"http://demowordpressapi.local/wp-content/uploads/2017/10/cat-300x200.jpeg 300w, http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" /></a></p>\n",
      "caption": "",
      "alt_text": "",
      "media_type": "image",
      "mime_type": "image/jpeg",
      "media_details": {
        "width": 640,
        "height": 427,
        "file": "2017/10/cat.jpeg",
        "image_meta": {
          "aperture": "0",
          "credit": "",
          "camera": "",
          "caption": "",
          "created_timestamp": "0",
          "copyright": "",
          "focal_length": "0",
          "iso": "0",
          "shutter_speed": "0",
          "title": "",
          "orientation": "0",
          "keywords": []
        }
      },
      "post": 6,
      "source_url": "http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg",
      "_links": {
        "self": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/media/20"
          }
        ],
        "collection": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/media"
          }
        ],
        "about": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/types/attachment"
          }
        ],
        "author": [
          {
            "embeddable": true,
            "href": "http://demowordpressapi.local/wp-json/wp/v2/users/1"
          }
        ],
        "replies": [
          {
            "embeddable": true,
            "href": "http://demowordpressapi.local/wp-json/wp/v2/comments?post=20"
          }
        ]
      },
      "id": "97c01a7a-4a9c-5fb4-a5cf-9cd50ae5cc86",
      "author___NODE": "ec1fb3e3-d897-5549-b5f6-72b358fbbe83",
      "localFile___NODE": "/Users/gary/DEVELOPMENT/acf-localfile-demo/.cache/gatsby-source-filesystem/b06517fb31d7c6c6ba874a381de8baa0.jpeg absPath of file",
      "children": [],
      "parent": null,
      "internal": {
        "type": "wordpress__wp_media",
        "contentDigest": "a1990108226cb75875a50ea8a4b05813",
        "owner": "gatsby-source-wordpress"
      }
    },

That appears to have the localFile mapping but it does not show in graphiql

@crgeary
Copy link
Contributor

crgeary commented Oct 19, 2017

I have the same issue, if there's no WP site up by tomorrow I can put a non-working example up for you.. unfortunately can't do it until tomorrow though 👍

@crgeary
Copy link
Contributor

crgeary commented Oct 20, 2017

Cool, so...

Gatsby: https://github.com/chrisgeary92/gatsby-wp-acf-media-issue
WP-API: https://deployasaurus.wpengine.com/wp-json/wp/v2/pages

Example query:

{
  allWordpressPage {
    edges {
      node {
        id
        featured_media {
          localFile {
            size
          }
        }
        acf {
          screenshot {
            wordpress_id
          }
        }
      }
    }
  }
}

You can't access localFile on acf.screenshot, but you can (for example) on featured_media.

If you need anything more, just let me know :)

@garytokyo
Copy link
Author

@chrisgeary92 that's awesome thanks for sorting that out! :)

@sebastienfi
Copy link
Contributor

As of yet, fields named featured_media with the Post ID as a number and any field name with a Picture Post Object are supported.

We could extend the naming conventions to a greater number of field names that would be reserved for photos, like image, photo, picture, ...

sebastienfi added a commit that referenced this issue Oct 27, 2017
* Most of the credits goes to @pieh for a better solution that solved the same problems and widely improved code simplicity. #2646
* Made the Media lookup begin at JSON tree root instead of keeping this for ACF Field only. Changed constants names accordingly.
* Making thise more generic allorws Custom Post Types to benefit from this improvements and yet unseen objects shapes. 
* Incorporated fix on bug mentionned here #2646 (comment)
* May solve this #2587, this #2492, this #2328
sebastienfi added a commit that referenced this issue Oct 27, 2017
#2648)

* Refactored featured_media map for deep nodes

* Featured medias coul be nested at any level
* The most certain way to have photos works with this version on the plugin is to either name the fiel featured_media or include the image as Post Object.
* Fixed bug where in some case the old featured_media field was not deleted.

* Update normalize.js.snap

* Integrated pieh 's changes

* Most of the credits goes to @pieh for a better solution that solved the same problems and widely improved code simplicity. #2646
* Made the Media lookup begin at JSON tree root instead of keeping this for ACF Field only. Changed constants names accordingly.
* Making thise more generic allorws Custom Post Types to benefit from this improvements and yet unseen objects shapes. 
* Incorporated fix on bug mentionned here #2646 (comment)
* May solve this #2587, this #2492, this #2328

* Update normalize.js.snap
@flmuel
Copy link
Contributor

flmuel commented Jan 7, 2018

I am running into this too at the moment... Installed everything new, still no localFile Node :(

@KyleAMathews
Copy link
Contributor

@flmuel does the WordPress example site work for you?

@flmuel
Copy link
Contributor

flmuel commented Jan 7, 2018

@KyleAMathews yes the example works...

@flmuel
Copy link
Contributor

flmuel commented Jan 7, 2018

no local file for me
screenshot 2018-01-07 14 26 06
only for the example
screenshot 2018-01-07 14 26 38

@KyleAMathews
Copy link
Contributor

Does your WordPress site have attached files? Gatsby dynamically creates the schemas from your data source(s).

@flmuel
Copy link
Contributor

flmuel commented Jan 7, 2018

Do you mean by attached files the media files that are connected with the acf fields? If yes, than I can confirm your question... The acf image fields are Media-Urls and not Objects or Ids.

@flmuel
Copy link
Contributor

flmuel commented Jan 7, 2018

Tried a kindy hacky alternative: I have placed the same images that are connected with the fields in WordPress in the Gatsby static folder. Now I am requiring the right image with "directory" + node->acf->image->slug + ".jpg"

It works and builds, but I do not like this solution... Netlify does not like this either and terminates the build process after:

Error: Module not found: Error: Cannot resolve 'file' or 'directory' ../static  /images in /opt/build/repo/src/templates
  resolve file
  resolve directory
    /opt/build/repo/src/static/images doesn't exist

@flmuel
Copy link
Contributor

flmuel commented Jan 14, 2018

Netlify works now, was an issue with yarn and sharp I think ... npm did the thing...
https://quirky-stonebraker-88058d.netlify.com/

but no localFile for me yet :(

@flmuel
Copy link
Contributor

flmuel commented Jan 16, 2018

So I have tracked this problem further down...
Example works, other WP Sites works as well - WP Sites with Basic Auth does not work...
So I console logged some vars in the compiled create-remote-file-node.js in gatsby-source-filesystem. The result was: everything fine (filenames were created, etc.) until

responseStream = got.stream(url, { headers });

something after this broke...
So I looked up the got package which needs auth options
Then I added another log before downloadProgress:

responseStream.on(`request`, function (pro) {
  console.log(pro);
});

which gave me this for each file:

ClientRequest {
  domain: null,
  _events: 
   { response: { [Function: bound onceWrapper] listener: [Function] },
     error: { [Function: bound onceWrapper] listener: [Function] } },
  _eventsCount: 2,
  _maxListeners: undefined,
  output: [],
  outputEncodings: [],
  outputCallbacks: [],
  outputSize: 0,
  writable: true,
  _last: true,
  upgrading: false,
  chunkedEncoding: false,
  shouldKeepAlive: false,
  useChunkedEncodingByDefault: false,
  sendDate: false,
  _removedConnection: false,
  _removedContLen: false,
  _removedTE: false,
  _contentLength: null,
  _hasBody: true,
  _trailer: '',
  finished: false,
  _headerSent: false,
  socket: 
   TLSSocket {
     _tlsOptions: 
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: true,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        NPNProtocols: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: false,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: null,
     npnProtocol: null,
     alpnProtocol: null,
     authorized: false,
     authorizationError: null,
     encrypted: true,
     _events: 
      { close: [Array],
        end: [Array],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        secureConnect: [Function],
        connect: [Array],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        data: [Function: socketOnData] },
     _eventsCount: 12,
     connecting: true,
     _hadError: false,
     _handle: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _parent: null,
     _host: 'flmueller001.dev.360vier.net',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _maxListeners: undefined,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     allowHalfOpen: false,
     _bytesDispatched: 0,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _requestCert: true,
     _rejectUnauthorized: true,
     parser: 
      HTTPParser {
        '0': [Function: parserOnHeaders],
        '1': [Function: parserOnHeadersComplete],
        '2': [Function: parserOnBody],
        '3': [Function: parserOnMessageComplete],
        '4': null,
        _headers: [],
        _url: '',
        _consumed: false,
        socket: [Circular],
        incoming: null,
        outgoing: [Circular],
        maxHeaderPairs: 2000,
        onIncoming: [Function: parserOnIncomingClient] },
     _httpMessage: [Circular],
     read: [Function],
     _consuming: true,
     [Symbol(res)]: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     [Symbol(asyncId)]: 2510,
     [Symbol(bytesRead)]: 0,
     [Symbol(connect-options)]: 
      { rejectUnauthorized: true,
        ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
        checkServerIdentity: [Function: checkServerIdentity],
        minDHSize: 1024,
        servername: 'flmueller001.dev.360vier.net',
        _defaultAgent: [Agent],
        path: null,
        retries: [Function],
        decompress: true,
        useElectronNet: true,
        protocol: 'https:',
        slashes: true,
        auth: null,
        host: 'flmueller001.dev.360vier.net',
        port: 443,
        hostname: 'flmueller001.dev.360vier.net',
        hash: null,
        search: null,
        query: null,
        pathname: '/wp-content/uploads/2018/01/test14.jpg',
        href: 'https://flmueller001.dev.360vier.net/wp-content/uploads/2018/01/test14.jpg',
        headers: [Object],
        method: 'GET',
        followRedirect: true,
        _agentKey: 'flmueller001.dev.360vier.net:443::::::::::',
        encoding: null,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        singleUse: true } },
  connection: 
   TLSSocket {
     _tlsOptions: 
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: true,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        NPNProtocols: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: false,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: null,
     npnProtocol: null,
     alpnProtocol: null,
     authorized: false,
     authorizationError: null,
     encrypted: true,
     _events: 
      { close: [Array],
        end: [Array],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        secureConnect: [Function],
        connect: [Array],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        data: [Function: socketOnData] },
     _eventsCount: 12,
     connecting: true,
     _hadError: false,
     _handle: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _parent: null,
     _host: 'flmueller001.dev.360vier.net',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _maxListeners: undefined,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     allowHalfOpen: false,
     _bytesDispatched: 0,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _requestCert: true,
     _rejectUnauthorized: true,
     parser: 
      HTTPParser {
        '0': [Function: parserOnHeaders],
        '1': [Function: parserOnHeadersComplete],
        '2': [Function: parserOnBody],
        '3': [Function: parserOnMessageComplete],
        '4': null,
        _headers: [],
        _url: '',
        _consumed: false,
        socket: [Circular],
        incoming: null,
        outgoing: [Circular],
        maxHeaderPairs: 2000,
        onIncoming: [Function: parserOnIncomingClient] },
     _httpMessage: [Circular],
     read: [Function],
     _consuming: true,
     [Symbol(res)]: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     [Symbol(asyncId)]: 2510,
     [Symbol(bytesRead)]: 0,
     [Symbol(connect-options)]: 
      { rejectUnauthorized: true,
        ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
        checkServerIdentity: [Function: checkServerIdentity],
        minDHSize: 1024,
        servername: 'flmueller001.dev.360vier.net',
        _defaultAgent: [Agent],
        path: null,
        retries: [Function],
        decompress: true,
        useElectronNet: true,
        protocol: 'https:',
        slashes: true,
        auth: null,
        host: 'flmueller001.dev.360vier.net',
        port: 443,
        hostname: 'flmueller001.dev.360vier.net',
        hash: null,
        search: null,
        query: null,
        pathname: '/wp-content/uploads/2018/01/test14.jpg',
        href: 'https://flmueller001.dev.360vier.net/wp-content/uploads/2018/01/test14.jpg',
        headers: [Object],
        method: 'GET',
        followRedirect: true,
        _agentKey: 'flmueller001.dev.360vier.net:443::::::::::',
        encoding: null,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        singleUse: true } },
  _header: null,
  _onPendingData: [Function: noopPendingOutput],
  agent: 
   Agent {
     domain: null,
     _events: { free: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     defaultPort: 443,
     protocol: 'https:',
     options: { path: null },
     requests: {},
     sockets: { 'flmueller001.dev.360vier.net:443::::::::::': [Array] },
     freeSockets: {},
     keepAliveMsecs: 1000,
     keepAlive: false,
     maxSockets: Infinity,
     maxFreeSockets: 256,
     maxCachedSessions: 100,
     _sessionCache: { map: [Object], list: [Array] } },
  socketPath: undefined,
  timeout: undefined,
  method: 'GET',
  path: '/wp-content/uploads/2018/01/test14.jpg',
  _ended: false,
  res: null,
  aborted: undefined,
  timeoutCb: null,
  upgradeOrConnect: false,
  parser: 
   HTTPParser {
     '0': [Function: parserOnHeaders],
     '1': [Function: parserOnHeadersComplete],
     '2': [Function: parserOnBody],
     '3': [Function: parserOnMessageComplete],
     '4': null,
     _headers: [],
     _url: '',
     _consumed: false,
     socket: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: false,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: null,
        alpnProtocol: null,
        authorized: false,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 12,
        connecting: true,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'flmueller001.dev.360vier.net',
        _readableState: [ReadableState],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _bytesDispatched: 0,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: [Circular],
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: 2510,
        [Symbol(bytesRead)]: 0,
        [Symbol(connect-options)]: [Object] },
     incoming: null,
     outgoing: [Circular],
     maxHeaderPairs: 2000,
     onIncoming: [Function: parserOnIncomingClient] },
  maxHeadersCount: null,
  [Symbol(outHeadersKey)]: 
   { 'user-agent': 
      [ 'user-agent',
        'got/7.1.0 (https://github.com/sindresorhus/got)' ],
     'accept-encoding': [ 'accept-encoding', 'gzip,deflate' ],
     host: [ 'Host', 'flmueller001.dev.360vier.net' ] } }

You can see that the output says "auth: null" - so I really think thats the matter of my issue (maybe not linked to this acf issue)...
I dont know how to fix this... but I have an idea: the headers variable which is transfered to the stream func of got is empty - maybe you have to put auth options there

@KyleAMathews
Copy link
Contributor

Ahhhhh! So we need to pass auth headers to createRemoteFileNode!

Could you work on a PR passing the right auth headers to got?

@flmuel
Copy link
Contributor

flmuel commented Jan 16, 2018

I dont know how...
I think you have to pass "_auth" from gatsby-node.js to normalize.js to create-remote-file-node.js, but then I have no idea how to pass this to got :(

@KyleAMathews
Copy link
Contributor

The wordpress auth instructions will need translated to HTTP headers similar to what's done in https://github.com/gatsbyjs/gatsby/blob/2bda70e3dd2b32499ee3fe9838dcd74fd570ace3/packages/gatsby-source-wordpress/src/fetch.js

create-remote-file-node.js would need the ability to take an object of headers.

@flmuel
Copy link
Contributor

flmuel commented Jan 20, 2018

Basic Auth fixed!

@bkonkle
Copy link
Contributor

bkonkle commented Jan 31, 2018

I'm starting to experience this on a public API - no basic auth. How should I start to track it down?

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Invariant Violation: GraphQLParser: Unknown field `localFile` on type `slideImage_4`. Source: document `HomepageQuery` file: `GraphQL request`.

@sebastienfi
Copy link
Contributor

sebastienfi commented Jan 31, 2018

The acf image fields are Media-Urls and not Objects or Ids.

Try the Link acf type, or anything that can send an image Object.

@sebastienfi
Copy link
Contributor

@bkonkle Please create a new issue

@Khristophor
Copy link
Contributor

@crgeary @KyleAMathews @garytokyo if this is at all still relevant, I think I figured out the root cause:

#6273 (comment)

Khristophor added a commit that referenced this issue Jul 27, 2018
…shooting information

Addresses #6273 and #2492 by including information for a temporary workaround until the issue is patched in WordPress core.
pieh pushed a commit that referenced this issue Jul 30, 2018
…shooting information (#6807)

Addresses #6273 and #2492 by including information for a temporary workaround until the issue is patched in WordPress core.
@pieh
Copy link
Contributor

pieh commented Jul 30, 2018

@Khristophor added troubleshooting guide that addresses this issue in #6807, so I'll close it. Feel free to re-open or open new issue if following new docs doesn't fix issue for You

@pieh pieh closed this as completed Jul 30, 2018
pieh pushed a commit to pieh/gatsby that referenced this issue Jul 31, 2018
…shooting information (gatsbyjs#6807)

Addresses gatsbyjs#6273 and gatsbyjs#2492 by including information for a temporary workaround until the issue is patched in WordPress core.
@MWalid
Copy link

MWalid commented Apr 29, 2019

For me post_parent = 0 solved it

UPDATE wp_posts SET post_parent = 0 WHERE post_type = 'attachment'

@lpluispacheco
Copy link

For me post_parent = 0 solved it

UPDATE wp_posts SET post_parent = 0 WHERE post_type = 'attachment'

Thanks, this help me on my issue!

Somebody know how to create a filter on WordPress when the user upload one photo type attachment the post_parent with value 0 by default?

Cheers!

@lauritowal
Copy link

lauritowal commented Nov 2, 2019

Thank you @MWalid. That fixed it for now. :)

@lpluispacheco did you find a solution for the filter already?

EDIT: no I was wrong. I just have the problem again.

@radscheit
Copy link

radscheit commented Jan 18, 2020

The WP-Plugin https://de.wordpress.org/plugins/media-library-assistant/ offers the feature to bulk set post_parent=0 within the Wordpress admin UI. @pieh Maybe it is useful to readers of your troubleshooting section.

@radscheit
Copy link

@lauritowal Same here, for me it just comes up during the night time, but I don't see any interesting issue in my server logs. I will call my hoster, maybe it is related to resources.

@lauritowal
Copy link

lauritowal commented Jan 20, 2020

Hi @radscheit For me using
GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop
or GATSBY_CONCURRENT_DOWNLOAD=8 gatsby build
fixed the problem. The host couldn't handle too many file requests at once from Gatsby. Just play around with the number.

@radscheit
Copy link

Hi @radscheit For me using
GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop
fixed the problem. The host couldn't handle too many file requests at once from Gatsby. Just play around with the number.

@lauritowal Thank you very much, saved my life! :)

@lauritowal
Copy link

lauritowal commented Feb 6, 2020

@radscheit

The WP-Plugin https://de.wordpress.org/plugins/media-library-assistant/ offers the feature to bulk set post_parent=0 within the Wordpress admin UI. @pieh Maybe it is useful to readers of your troubleshooting section.

Stupid question.. But how? :D

@radscheit
Copy link

@lauritowal

  1. Install and activate the plugin
  2. Navigate to Media > Assistant
  3. Select the items you want to change and choose Edit in the bulk action dropdown
  4. Now choose a new parent id and voilá

Screenshot 2020-02-08 at 10 09 57

Did it help you?

@zakirsajib
Copy link

GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
Projects
None yet
Development

No branches or pull requests