This may be an unrelated issue but I am getting the error when trying fetch cache after using createRemoteFileNode from gatsby-source-filesystem.
let updated = {}
if (res[`webImages`]) {
const updatedImages = await Promise.all(
res[`webImages`].map(async img => {
let fileNodeID
const webImageCacheKey = `web-images-${img.id}`
// TypeError: Cannot read property 'internal' of null on 2nd run . <--- this is were I get this error after the cache has been stored the first time.
const cacheMediaData = await cache.get(webImageCacheKey)
if (cacheMediaData) {
fileNodeID = cacheMediaData.fileNodeID
touchNode({ nodeId: cacheMediaData.fileNodeID })
}
if (!fileNodeID) {
try {
const fileNode = await createRemoteFileNode({
url: cloud(img.url, `w_2000`, `dn_72`),
store,
cache,
createNode,
createNodeId,
})
if (fileNode) {
fileNodeID = fileNode.id
await cache.set(webImageCacheKey, {
fileNodeID,
})
}
} catch (e) {
// Ignore
console.log(`ERROR ${e}`)
}
}
if (fileNodeID) {
return fileNodeID
}
}),
)
updated.localWebImages___NODE = updatedImages
}
console.log(updated)
return { ...node, ...updated }
TypeError: Cannot read property 'internal' of null
- infer-graphql-input-fields.js:254
[escalade-sports]/[gatsby]/dist/schema/infer-graphql-input-fields.js:254:38
- lodash.js:4925
[escalade-sports]/[lodash]/lodash.js:4925:15
- lodash.js:3010 baseForOwn
[escalade-sports]/[lodash]/lodash.js:3010:24
- lodash.js:4894
[escalade-sports]/[lodash]/lodash.js:4894:18
- lodash.js:9342 Function.forEach
[escalade-sports]/[lodash]/lodash.js:9342:14
- infer-graphql-input-fields.js:241 inferInputObjectStructureFromNodes
[escalade-sports]/[gatsby]/dist/schema/infer-graphql-input-fields.js:241:5
- build-node-types.js:91 _callee$
[escalade-sports]/[gatsby]/dist/schema/build-node-types.js:91:36
- next_tick.js:131 _combinedTickCallback
internal/process/next_tick.js:131:7
- next_tick.js:180 process._tickCallback
internal/process/next_tick.js:180:9
@tbaustin can you provide a minimal reproduction repo of your code showing the error? What version of Gatsby are you running?
Using version 1.9.277. I will get the repo up soon sorry about that.
Here is the repo. Stay on the tbaustin branch. https://github.com/escaladesports/gatsby-source-salsify/tree/tbaustin
I am having to delete the local cache to get it to work if that helps any.
@Chuloo I found where this is breaking. The fileNodeID when cached is grabbed and skips the createRemoteFileNode making process. It is then assigned from the cacheMediaData.fileNodeID as you can see it is just returned and should be plugged into the array. This is where the error comes up, when the createRemoteFileNode process is skipped. Maybe I should just not do caching?
I am no pro at this, but I think the fileNodeID is referencing a Node that was created. So when we rerun the dev, the nodes aren't created and the fileNodeIDhas nothing to reference and this is where I think the error comes up?
I am not sure though, because this is how they are doing it in the wordpress-plugin so I would assume this should work just fine.
Anyone knows why this is happening? My page was working fine, I did an update on one of my pages inside of WordPress, after I re-run gatsby-develop, the page broke showing the same error
TypeError: Cannot read property 'internal' of null
gatsby: ^1.9.247 => 1.9.277
@tbaustin couldn't reproduce your error while running the repo you shared. Did you change anything? Stayed on the tbaustin branch.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub issues, we have to clean some of the old issues as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Gatsby version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
We have put this off for now so maybe with new gatsby it will fix this. I will re visit this later when I get some time! Until then I'm going to close this.
We had the same error message appearing and also resorted to removing the /.cache on start.
However, this is how we just fixed it:
createRemoteFileNode in onCreateNode. We moved this to sourceNodes.touchNode to tell Gatsby to not garbage collect the node. We were using gatsby-source-wordpress as guidance in this regard: https://github.com/gatsbyjs/gatsby/blob/24c7dfc754a09cae8cf2e863261f63f9dd44e48d/packages/gatsby-source-wordpress/src/normalize.js#L475-L483