Gatsby:在页面节点上调用 `touchNode` 会抛出“TypeError: locationAndPageResources.pageResources is undefined”

Nat*_*gan 1 javascript reactjs gatsby

当您转到希望缓存的页面时,在页面上(从源插件)调用 touchNode 会导致以下错误:

类型错误:locationAndPageResources.pageResources 未定义

触摸节点调用:

// Code here checks if the page node in Gatsby cache is the same version 
// as backend version. If so 'touch it' and don't recreate.
await Promise.all(result.data.pages.map(async page => {
    const pageCacheKey = `cache-${page.url}`
    const cacheResult = await pageRecords.getKey(pageCacheKey)
    if (cacheResult) {
        const node = pageNodes.find(node => {
            if (!node.context)
                return
            return node.context.url == page.url
        })

        if (node) {
            if (node.context.lastPublishedAt == page.lastPublishedAt) {
              pageRecords.setKey(pageCacheKey, localPublishedAt)
              return touchNode({
                nodeId: node.id
              })
            }
        }
    }
  }))
Run Code Online (Sandbox Code Playgroud)

预期结果

页面节点应该持续存在而不必重新创建它(并且不需要后端)。

实际结果

在此处输入图片说明

nfl*_*ria 5

删除我的 index.js 文件后,我遇到了同样的错误。
我跑了gatsby clean然后gatsby develop。这解决了问题。