Open seungpark opened 8 months ago
Hey @seungpark ,
Your assets download script is not catching up with Gatsby nodes API at all. Use createRemoteFileNode
instead.
https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/#createremotefilenode
exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }) => {
const { createNode } = actions;
...
for (const image of remoteImages) {
try {
const fileNode = await createRemoteFileNode({
url: image.url, // string that points to the URL of the image
parentNodeId: node.id, // id of the parent node of the fileNode you are going to create
createNode, // helper function in gatsby-node to generate the node
createNodeId, // helper function in gatsby-node to generate the node id
getCache,
});
} catch (error) {
console.log(error);
}
}
remoteImages
is just array of image urls
Hey @seungpark , Your assets download script is not catching up with Gatsby nodes API at all. Use
createRemoteFileNode
instead. https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/#createremotefilenodeexports.sourceNodes = async ({ actions, createNodeId, createContentDigest }) => { const { createNode } = actions; ...
for (const image of remoteImages) { try { const fileNode = await createRemoteFileNode({ url: image.url, // string that points to the URL of the image parentNodeId: node.id, // id of the parent node of the fileNode you are going to create createNode, // helper function in gatsby-node to generate the node createNodeId, // helper function in gatsby-node to generate the node id getCache, }); } catch (error) { console.log(error); } }
remoteImages
is just array of image urls
@olehpratsko instead of creating my own gatsby nodes, i am using gatsby filesystem to create image gatsby nodes of files where i save the assets
@seungpark good workaround, I'll take it to the note. Thank you for sharing.
Preliminary Checks
Description
Gatsby transformer sharp throws intermittent errors during the build schema process:
Accompanying gatsby-config plugins:
In gatsby-node.js:
This error is not consistent, and it seems to be complaining about a
ADD_CHILD_TO_NODE
action.type case, at this line.However, when debugging the build locally, the build always succeeds and I am able to see the ImageSharp nodes (as children of File nodes) in the graphql explorer.
Reproduction Link
https://github.com/seungpark/gatsby-reproduction
Steps to Reproduce
gatsby build
and look for error while in stepsource and transform nodes
...Expected Result
I would expect this to be an error or success 100% of the time. Intermittent errors have been a pain for debugging. Ideally, this would be a successful Image Sharp node creation for each Image type file.
Actual Result
This error is thrown sometimes on the same build, but not 100%
Environment
Config Flags
No response