Gatsby: [gatsby-source-wordpress] 大型 WordPress 站点导致构建时间极慢(卡在“源和转换节点”)

创建于 2018-07-22  ·  156评论  ·  资料来源: gatsbyjs/gatsby

描述

在查询大型 WordPress 安装(约 9000 个帖子,约 35 页)后, gatsby develop挂在source and transform nodes

是否有任何指南可以说明在这方面 Gatsby 无法处理什么太大的问题?

环境

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.10.0 - ~/n/bin/node
    Yarn: 1.5.1 - ~/n/bin/yarn
    npm: 5.6.0 - ~/n/bin/npm
  Browsers:
    Chrome: 67.0.3396.99
    Safari: 11.1.2
  npmPackages:
    gatsby: ^1.9.273 => 1.9.273
    gatsby-image: ^1.0.54 => 1.0.54
    gatsby-link: ^1.6.45 => 1.6.45
    gatsby-plugin-google-analytics: ^1.0.27 => 1.0.31
    gatsby-plugin-postcss-sass: ^1.0.22 => 1.0.22
    gatsby-plugin-react-helmet: ^2.0.10 => 2.0.11
    gatsby-plugin-react-next: ^1.0.11 => 1.0.11
    gatsby-plugin-resolve-src: 1.1.3 => 1.1.3
    gatsby-plugin-sharp: ^1.6.48 => 1.6.48
    gatsby-plugin-svgr: ^1.0.1 => 1.0.1
    gatsby-source-filesystem: ^1.5.39 => 1.5.39
    gatsby-source-wordpress: ^2.0.93 => 2.0.93
    gatsby-transformer-sharp: ^1.6.27 => 1.6.27
  npmGlobalPackages:
    gatsby-cli: 1.1.58

编辑:只是想重申 - 这不是通过删除.cache/.node_modules等轻易解决的问题。如果这解决了您的问题,则您没有遇到此问题。

最有用的评论

伙计们,我设法通过串行而不是并行运行 createRemoteFileNode 请求来解决这个问题。

是的,这个问题实际上是基于createRemoteFileNode使用 200 的并发性这一事实,这对于大多数 WP 服务器来说太多了。 我在 CloudFront 上有我的图像并且在那里达到了一些速率限制。

我尝试使用源插件的分支版本解决了一段时间的问题,但问题确实不在gatsby-source-wordpress ,而是在gatsby-source-filesystem 。 理想情况下, createRemoteFileNode函数的使用者将能够在那里传递并发。 然后插件可以在其配置中提供并发选项。 我还是想做个 PR 来解决这个问题!

我一直在使用的解决方案只是一个简单的脚本来修改node_modules的代码。 确实非常脆弱且不理想,但直接修改并发是一种简单的技巧。 使用shelljs所以它应该也适用于 Windows 用户(还没有尝试过)。

#!/usr/bin/env node
const path = require('path');
const shell = require('shelljs');

const FILE_PATH = path.resolve(
  __dirname,
  // add path to your root dir here,
  'node_modules',
  'gatsby-source-filesystem/create-remote-file-node.js'
);

shell.sed('-i', 'concurrent: 200', 'concurrent: 20', FILE_PATH);

所有156条评论

你能准备复制回购吗? 帖子数量不应该是问题(至少在此步骤中)- v1 可能会遇到内存问题,但这将在稍后的构建步骤中进行,不应卡住

很好奇这是否是Local by Flywheel的问题,并且能够在通过MAMP Pro为 WordPress 提供服务时构建站点。

但是,我什至还没有构建帖子页面(正在构建页面),并且那个有问题的步骤的执行时间是 636.41 秒(不到 11 分钟)。

const path = require('path')

exports.createPages = ({ boundActionCreators, graphql }) => {
  const { createPage } = boundActionCreators

  const postTemplate = path.resolve('./src/templates/Post/Post.js')

  graphql(
    `
      {
        allWordpressPost {
          edges {
            node {
              id
              slug
            }
          }
        }
      }
    `
  )
    .then((result) => {
      console.log('posts')
      // const { data, errors } = result

      // if (errors) console.log(errors)

      // if (!data) return

      //data.allWordpressPost.edges.forEach(({ node }) => {
      //  const { id, slug } = node

      //  createPage({
      //    component: postTemplate,
      //    context: {
      //      id,
      //    },
      //    path: slug,
      //  })
      //})
    })

编辑:只需为帖子启用createPage ,该项目的执行时间增加到 14 分钟。 残酷,但也很有趣,大约 9000 多件物品的时间仅延长了 3 分钟。 目前它在⠁ run graphql queries上坐了很长时间。

编辑:运行了 419.470 秒,或 7 分钟。

@pieh哎呀,在我看到你刚刚回复之前就发布了。 明天我可以尝试远程启动这个站点。

并且意味着包括,最后一行是它通过 Local 挂起的地方,并通过 MAMP 永远存在。

$ gatsby develop
success delete html and css files from previous builds — 0.017 s
success open and validate gatsby-config — 0.226 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success copy gatsby files — 0.013 s
success onPreBootstrap — 0.159 s
⠁ source and transform nodes -> wordpress__acf_posts fetched : 100
⠁ source and transform nodes -> wordpress__acf_pages fetched : 34
⠂ source and transform nodes -> wordpress__acf_media fetched : 100
⠈ source and transform nodes -> wordpress__acf_categories fetched : 13
⢀ source and transform nodes -> wordpress__acf_tags fetched : 0
⠄ source and transform nodes -> wordpress__acf_users fetched : 11
⢀ source and transform nodes -> wordpress__POST fetched : 9092
⢀ source and transform nodes -> wordpress__PAGE fetched : 34
⠐ source and transform nodes -> wordpress__wp_media fetched : 7483
⡀ source and transform nodes -> wordpress__wp_types fetched : 1
⠁ source and transform nodes -> wordpress__wp_statuses fetched : 1
⢀ source and transform nodes -> wordpress__wp_taxonomies fetched : 1
⠄ source and transform nodes -> wordpress__CATEGORY fetched : 14
⠈ source and transform nodes -> wordpress__TAG fetched : 19
⠐ source and transform nodes -> wordpress__wp_users fetched : 11
⡀ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "You are not currently logged in."
⠈ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
⡀ source and transform nodesThe server response was "404 Not Found"
Inner exception message : "No route was found matching the URL and request method"
success source and transform nodes — 636.410 s

@pieh还没有确认这会成功构建(现在使用 WordPress 遥控器,这需要几个小时),但它肯定揭示了问题: https :

应该能够克隆它并构建。

只跑了两次超过 10 个小时,没有完成站点的建设。 请让我知道我还能提供什么帮助调试。

您可以尝试升级到 v2 吗? 我们对不同的 gatsby 子系统进行了大量的速度改进,这应该可以显着加快此类大型站点的速度。

@KyleAMathews我今晚会

@KyleAMathews v2 版本 @ https://github.com/dustinhorton/gatsby-v2-issue。 此时已经构建了大约 50 分钟。

现在杀了它。 网站还没建好。

您可以尝试的另一件事是启用跟踪https://next.gatsbyjs.org/docs/performance-tracing/

我们还没有为 gatsby-source-wordpress 添加跟踪支持,但跟踪报告可能会帮助您找出它在哪里停滞。

如果其他人对此感兴趣,一个很好的 PR 是为 gatsby-source-wordpress 添加跟踪支持。 让我知道你是否有兴趣!

不幸的是,我需要为此纾困,因为我需要花所有时间来移植到一个传统的主题——无法使用 Gatsby 有点被压垮了。 其他一切都感觉如此倒退。

抱歉,我们还没有机会研究这个 :-( 现在正在冲刺以推出 v2。

您是否有可能让 WP 网站继续运行? 看起来这里肯定有一个应该修复的错误。

我在推特上寻求帮助,所以希望有人很快就会加入这个 :-)

https://twitter.com/gatsbyjs/status/1027079401287102465

哇,太棒了——非常感谢。 站点暂时不会去任何地方(如果需要,我将迁移副本并更新 repro 存储库)。

@dustinhorton值得一提的是,我还注意到,与前面带有 CDN 的生产环境相比,通过 Flywheel 在 Local 上构建更大(约 1,000 个帖子)项目时存在问题。

来自本地的 Gatsby REST 响应比来自生产的 REST 响应时间长 10-20 倍,因此该站点需要很长时间来构建。 我还没有花时间在本地调试这个问题,但它在我的待办事项清单上:)

@KyleAMathews我可以看看向 source-wordpress 添加跟踪。

@Khristophor那太好了!

@dustinhorton我在您的示例站点(例如,https:

WP_MEDIA 请求运行得相当快,结果让我觉得我在
很清楚,但如果你认为的话,我可以在本周晚些时候看看
可能是这样。

2018 年 8 月 8 日,星期三,下午 5:45,Chris Wiseman通知@ github.com
写道:

@dustinhorton https://github.com/dustinhorton我看到了 404
示例站点上的图像(
https://dustinhorton.com/gatsby-wp/wp-content/uploads/2018/07/IMG_9906.jpg,
例如)这可能会增加构建时间。 任何你可以的机会
查看那些路径?


你收到这个是因为你被提到了。
直接回复本邮件,在GitHub上查看
https://github.com/gatsbyjs/gatsby/issues/6654#issuecomment-411562589
或静音线程
https://github.com/notifications/unsubscribe-auth/AAXFNRHTA-vqIwCTtioejUL-Ei3nM0Lbks5uO1vygaJpZM4VZ57n
.

这是真的,但源和转换步骤的一部分是下载它在 REST 响应中找到的所有媒体项:
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-wordpress/src/normalize.js#L434

在 7504 图像上获取 404 可能会导致一些问题;)

相信我已经清理了所有的 404。 今晚会尝试建造。 谢谢大家。

貌似没什么变化:

~/Sites/gatsby-issue-v2 (master)
→yarn build
yarn run v1.5.1
$ gatsby build
success open and validate gatsby-config — 0.009 s
success load plugins — 0.277 s
success onPreInit — 0.257 s
success delete html and css files from previous builds — 0.008 s
success initialize cache — 0.245 s
success copy gatsby files — 0.079 s
success onPreBootstrap — 0.001 s
⠁
=START PLUGIN=====================================

Site URL: http://dustinhorton.com/gatsby-wp
Site hosted on Wordpress.com: false
Using ACF: true
Using Auth: undefined undefined
Verbose output: true

Mama Route URL: http://dustinhorton.com/gatsby-wp/wp-json

⠁ source and transform nodesRoute discovered : /
Invalid route.
Route discovered : /oembed/1.0
Invalid route.
Route discovered : /oembed/1.0/embed
Invalid route.
Route discovered : /oembed/1.0/proxy
Invalid route.
Route discovered : /yoast/v1
Valid route found. Will try to fetch.
Route discovered : /yoast/v1/configurator
Valid route found. Will try to fetch.
Route discovered : /yoast/v1/reindex_posts
Valid route found. Will try to fetch.
Route discovered : /yoast/v1/ryte
Valid route found. Will try to fetch.
Route discovered : /yoast/v1/indexables/(?P<object_type>.*)/(?P<object_id>\d+)
Invalid route.
Route discovered : /yoast/v1/statistics
Valid route found. Will try to fetch.
Route discovered : /acf/v3
Invalid route.
Route discovered : /acf/v3/posts/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/posts
Valid route found. Will try to fetch.
Route discovered : /acf/v3/pages/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/pages
Valid route found. Will try to fetch.
Route discovered : /acf/v3/media/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/media
Valid route found. Will try to fetch.
Route discovered : /acf/v3/categories/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/categories
Valid route found. Will try to fetch.
Route discovered : /acf/v3/tags/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/tags
Valid route found. Will try to fetch.
Route discovered : /acf/v3/comments/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/comments
Valid route found. Will try to fetch.
Route discovered : /acf/v3/options/(?P<id>[\w\-\_]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/users/(?P<id>[\d]+)/?(?P<field>[\w\-\_]+)?
Invalid route.
Route discovered : /acf/v3/users
Valid route found. Will try to fetch.
Route discovered : /wp/v2
Invalid route.
Route discovered : /wp/v2/posts
Valid route found. Will try to fetch.
Route discovered : /wp/v2/posts/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions
Invalid route.
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/pages
Valid route found. Will try to fetch.
Route discovered : /wp/v2/pages/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions
Invalid route.
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/media
Valid route found. Will try to fetch.
Route discovered : /wp/v2/media/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/types
Valid route found. Will try to fetch.
Route discovered : /wp/v2/types/(?P<type>[\w-]+)
Invalid route.
Route discovered : /wp/v2/statuses
Valid route found. Will try to fetch.
Route discovered : /wp/v2/statuses/(?P<status>[\w-]+)
Invalid route.
Route discovered : /wp/v2/taxonomies
Valid route found. Will try to fetch.
Route discovered : /wp/v2/taxonomies/(?P<taxonomy>[\w-]+)
Invalid route.
Route discovered : /wp/v2/categories
Valid route found. Will try to fetch.
Route discovered : /wp/v2/categories/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/tags
Valid route found. Will try to fetch.
Route discovered : /wp/v2/tags/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/users
Valid route found. Will try to fetch.
Route discovered : /wp/v2/users/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/users/me
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments/(?P<id>[\d]+)
Invalid route.
Route discovered : /wp/v2/settings
Valid route found. Will try to fetch.
Added ACF Options route.

Fetching the JSON data from 25 valid API Routes...

=== [ Fetching wordpress__yoast_v1 ] === https://dustinhorton.com/gatsby-wp/wp-json/yoast/v1
⠈ source and transform nodes -> wordpress__yoast_v1 fetched : 1
Fetching the wordpress__yoast_v1 took: 936.166ms

=== [ Fetching wordpress__yoast_configurator ] === https://dustinhorton.com/gatsby-wp/wp-json/yoast/v1/configurator
⢀ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
Fetching the wordpress__yoast_configurator took: 846.014ms

=== [ Fetching wordpress__yoast_reindex_posts ] === https://dustinhorton.com/gatsby-wp/wp-json/yoast/v1/reindex_posts
⢀ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
Fetching the wordpress__yoast_reindex_posts took: 1010.589ms

=== [ Fetching wordpress__yoast_ryte ] === https://dustinhorton.com/gatsby-wp/wp-json/yoast/v1/ryte
⠠ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
Fetching the wordpress__yoast_ryte took: 1022.977ms

=== [ Fetching wordpress__yoast_statistics ] === https://dustinhorton.com/gatsby-wp/wp-json/yoast/v1/statistics
⠄ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
Fetching the wordpress__yoast_statistics took: 820.827ms

=== [ Fetching wordpress__acf_posts ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/posts
⠈ source and transform nodes -> wordpress__acf_posts fetched : 100
Fetching the wordpress__acf_posts took: 6352.670ms

=== [ Fetching wordpress__acf_pages ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/pages
⡀ source and transform nodes -> wordpress__acf_pages fetched : 34
Fetching the wordpress__acf_pages took: 2760.048ms

=== [ Fetching wordpress__acf_media ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/media
⠈ source and transform nodes -> wordpress__acf_media fetched : 100
Fetching the wordpress__acf_media took: 4273.250ms

=== [ Fetching wordpress__acf_categories ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/categories
⠁ source and transform nodes -> wordpress__acf_categories fetched : 13
Fetching the wordpress__acf_categories took: 1029.029ms

=== [ Fetching wordpress__acf_tags ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/tags
⠈ source and transform nodes -> wordpress__acf_tags fetched : 0
Fetching the wordpress__acf_tags took: 941.066ms

=== [ Fetching wordpress__acf_comments ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/comments
⢀ source and transform nodes -> wordpress__acf_comments fetched : 9
Fetching the wordpress__acf_comments took: 2868.036ms

=== [ Fetching wordpress__acf_users ] === https://dustinhorton.com/gatsby-wp/wp-json/acf/v3/users
⠠ source and transform nodes -> wordpress__acf_users fetched : 11
Fetching the wordpress__acf_users took: 2049.181ms

=== [ Fetching wordpress__POST ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/posts
⠁ source and transform nodes
Total entities : 9094
Pages to be requested : 91
⠁ source and transform nodes -> wordpress__POST fetched : 9094
Fetching the wordpress__POST took: 152767.807ms

=== [ Fetching wordpress__PAGE ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/pages
⢀ source and transform nodes -> wordpress__PAGE fetched : 34
Fetching the wordpress__PAGE took: 2194.895ms

=== [ Fetching wordpress__wp_media ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media
⢀ source and transform nodes
Total entities : 7504
Pages to be requested : 76
⢀ source and transform nodes -> wordpress__wp_media fetched : 7485
Fetching the wordpress__wp_media took: 132029.996ms

=== [ Fetching wordpress__wp_types ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/types
⢀ source and transform nodes -> wordpress__wp_types fetched : 1
Fetching the wordpress__wp_types took: 956.603ms

=== [ Fetching wordpress__wp_statuses ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/statuses
⢀ source and transform nodes -> wordpress__wp_statuses fetched : 1
Fetching the wordpress__wp_statuses took: 1017.845ms

=== [ Fetching wordpress__wp_taxonomies ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/taxonomies
⠠ source and transform nodes -> wordpress__wp_taxonomies fetched : 1
Fetching the wordpress__wp_taxonomies took: 1029.885ms

=== [ Fetching wordpress__CATEGORY ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/categories
⢀ source and transform nodes -> wordpress__CATEGORY fetched : 14
Fetching the wordpress__CATEGORY took: 943.710ms

=== [ Fetching wordpress__TAG ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/tags
⠠ source and transform nodes -> wordpress__TAG fetched : 19
Fetching the wordpress__TAG took: 1104.454ms

=== [ Fetching wordpress__wp_users ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/users
⡀ source and transform nodes -> wordpress__wp_users fetched : 11
Fetching the wordpress__wp_users took: 1325.604ms

=== [ Fetching wordpress__wp_me ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/users/me
⠂ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "You are not currently logged in."
Fetching the wordpress__wp_me took: 926.146ms

=== [ Fetching wordpress__wp_comments ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/comments
⠂ source and transform nodes
Total entities : 9410
Pages to be requested : 95
⡀ source and transform nodes -> wordpress__wp_comments fetched : 9397
Fetching the wordpress__wp_comments took: 85370.673ms

=== [ Fetching wordpress__wp_settings ] === https://dustinhorton.com/gatsby-wp/wp-json/wp/v2/settings
⠁ source and transform nodesThe server response was "401 Unauthorized"
Inner exception message : "Sorry, you are not allowed to do that."
Fetching the wordpress__wp_settings took: 808.396ms

=== [ Fetching wordpress__acf_options ] === http://dustinhorton.com/gatsby-wp/wp-json/acf/v2/options
⠂ source and transform nodesThe server response was "404 Not Found"
Inner exception message : "No route was found matching the URL and request method"
Fetching the wordpress__acf_options took: 1059.276ms

=END PLUGIN=====================================: 412457.896ms
⠁ source and transform nodes

它已经在那里坐了大约 8 个小时。

@dustinhorton您使用的是哪种主机? 我认为它只是用大量的请求杀死了你的生产箱。 我相信我已经完成了(经过相当长的一段时间,而不是八小时)将并发连接设置为较低的值,例如 1 或 2。

这是 Linode 上不错的 VPS。 如果有帮助,我可以调整设置。 但问题也发生在本地。

https://github.com/gatsbyjs/gatsby/blob/46290c2b0e7894fca036bdcc658a5d1936c4221f/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L133 -L159 当我们有时无法正确拉取较大量时文件 - 网络请求得到解决,但文件写入流永远不会完成(或错误输出)。 我认为在responseStream完成后添加某种超时以等待fsWriteStream完成会很棒,如果它没有并销毁所有资源并尝试再次写入文件(可能很少重试),当它实际上不能这样做时,实际上会出错。

@pieh能否请您发送此文件的更新代码?

/packages/gatsby-source-filesystem/src/create-remote-file-node.js

@aman-developer 目前还没有修复这个问题——否则它会被发布。 这个问题的问题是没有可靠的方法来重现这个问题,所以任何修复都是猜测。 问题是在某些情况下(可能是硬件和/或操作系统特定的)文件系统 writeStream 没有完成并且在没有抛出错误的情况下卡住,所以这里的任何修复实际上都是试图解决fs包/硬件/操作系统中的问题不可靠:/

你在我的回购和网站上有问题吗? 这对我来说是一致的。

我使用 createRemoteFileNode 来获取远程图像,但我遇到了同样的问题:下载卡在 680/780ish 左右。

在 createRemoteFileNode 中, https: //github.com/sindresorhus/got/releases/tag/v8.0.0 中添加了downloadProgress事件的侦听器,但 gatsby-source-filesystem 使用的是 7.1.0。

我尝试升级到最新版本 9.2.2,现在可以成功下载所有图像。

在 package.json 中添加:

  "resolutions": {
    "got": "^9.2.2"
  }

在 7.1.0 之后似乎还有一些关键的修复,比如流错误没有被正确转发等(https://github.com/sindresorhus/got/releases/tag/v8.0.1)

我尝试更新got ,但有时仍然会卡住,但无论如何都值得这样做。 请注意downloadProgress东西要么需要禁用,要么需要一些更好的输出,因为终端/控制台在使用它时会收到垃圾邮件

我能够在大约 25 分钟后运行gatsby develop但我不得不将 create-remote-file-node.js 中的并发性从 200 减少到 20。我确实收到了一些 22 TimeoutErrors(但在执行 gatsby develop 时重新下载再次)将日志放入 processRemoteNode 中的空捕获之后。

不知道是不是因为得到了,但也许可以用其他 http 客户端进行试验......

...
success source and transform nodes — 1407.531 s
success building schema — 3.315 s
success createPages — 0.571 s
success createPagesStatefully — 2.797 s
success onPreExtractQueries — 0.012 s
success update schema — 3.268 s
warning There are conflicting field types in your data. GraphQL schema will omit those fields.
wordpress__wp_media.media_details.width:
 - type: number
   value: 916
 - type: string
   value: '224'
wordpress__wp_media.media_details.height:
 - type: number
   value: 916
 - type: string
   value: '225'
wordpress__wp_media.media_details.sizes.thumbnail.width:
 - type: number
   value: 150
 - type: string
   value: '150'
wordpress__wp_media.media_details.sizes.thumbnail.height:
 - type: number
   value: 150
 - type: string
   value: '150'
wordpress__wp_media.media_details.sizes.medium.width:
 - type: number
   value: 300
 - type: string
   value: '300'
wordpress__wp_media.media_details.sizes.medium.height:
 - type: number
   value: 300
 - type: string
   value: '200'
wordpress__wp_media.media_details.sizes.large.width:
 - type: number
   value: 768
 - type: string
   value: '1024'
wordpress__wp_media.media_details.sizes.large.height:
 - type: number
   value: 1024
 - type: string
   value: '682'
wordpress__wp_media.media_details.image_meta.aperture:
 - type: number
   value: 2.2
 - type: string
   value: '0'
wordpress__wp_media.media_details.image_meta.created_timestamp:
 - type: boolean
   value: false
 - type: number
   value: 1433226914
 - type: string
   value: '0'
wordpress__wp_media.media_details.image_meta.focal_length:
 - type: number
   value: 0
 - type: string
   value: '0'
wordpress__wp_media.media_details.image_meta.iso:
 - type: number
   value: 0
 - type: string
   value: '0'
wordpress__wp_media.media_details.image_meta.shutter_speed:
 - type: number
   value: 0
 - type: string
   value: '0'
wordpress__wp_media.media_details.image_meta.orientation:
 - type: number
   value: 1
 - type: string
   value: '1'
warning Using the global `graphql` tag is deprecated, and will not be supported in v3.
Import it instead like:  import { graphql } from 'gatsby' in file:
/Users/tandingan.wlb/Projects/gatsby/gatsby-issue/src/templates/Post/Post.js
success extract queries from components — 0.120 s
success run graphql queries — 223.335 s — 9121/9121 40.84 queries/second
success write out page data — 0.119 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.027 s

info bootstrap finished - 1643.854 s
{ TimeoutError: Timeout awaiting 'request' for 30000ms
    at Immediate.timeoutHandler [as _onImmediate] (/Users/tandingan.wlb/Projects/gatsby/gatsby-issue/node_modules/got/source/timed-out.js:39:25)
    at runCallback (timers.js:694:11)
    at tryOnImmediate (timers.js:664:5)
    at processImmediate (timers.js:646:5)
  name: 'TimeoutError',
  code: 'ETIMEDOUT',
  host: 'dustinhorton.com',
  hostname: 'dustinhorton.com',
  method: 'GET',
  path: '/gatsby-wp/wp-content/uploads/2015/05/20150302_061259.jpg',
  socketPath: undefined,
  protocol: 'https:',
  url:
   'https://dustinhorton.com/gatsby-wp/wp-content/uploads/2015/05/20150302_061259.jpg',
  event: 'request' }

我在使用棱镜时遇到了同样的错误

我升级到 "got": "^9.2.2" 现在它正在工作!

绝对需要看看升级我们的got版本。 这是间歇性问题,因此它起作用可能是巧合。 @RobinHerzog请让我们知道您是否会遇到升级版got类似问题

更新got显着减少了我的 repro 存储库的构建时间,但我上次尝试仍然花了将近一个小时。

@dustinhorton构建的哪一部分正在提取图像(或source and transform data因为我们没有明确显示下载文件需要多长时间)?

我有 150MB 的图像和 1GB 的互联网连接。 现在它正在运行。我需要 30 秒来下载并继续构建。

我也一直有这个问题。 升级got并没有为我解决这个问题。 向 source-wordpress 添加额外跟踪是否成功,以便我们可以尝试调试问题所在?

尝试更改concurrentRequestsperPage ,以及将got升级到最新版本,但没有任何效果。 现在我可以获取categoriespostspagestags ,但是当我包含usersmedia ,在=END PLUGIN=== ,插件返回错误: TypeError: Cannot read property 'id' of undefined

如果我包含所有路线并将我无法访问的路线列入黑名单,我会得到=END PLUGIN===但它永远不会完成......这适用于我测试的大量网站,所以我认为这可能是我的系统. 如果有人想测试这个,这是配置:

    {
      resolve: 'gatsby-source-wordpress',
      options: {
        // Other URLs I tried:
        // https://clubedovalor.com.br
        // http://rivainvestimentos.com.br
        // http://queroinvestiragora.com/
        // https://www.clubedospoupadores.com/
        baseUrl: "aprenda.guiainvest.com.br",
        protocol: "https",
        hostingWPCOM: false,
        useACF: false,
        concurrentRequests: 10,
        perPage: 50,
        // Going with the excluded routes path
        // excludedRoutes: [
        //   '/*/*/plugins',
        //   '/rock-convert/**',
        //   '/yoast/**',
        //   '/wp-super-cache/**',
        //   '/*/*/users/me',
        //   '/*/*/settings',
        // ],
        verboseOutput: true,
        includedRoutes: [
          "/*/*/categories",
          "/*/*/posts",
          "/*/*/pages",
          "/*/*/tags",
          // You can toggle between media and users (or both)
          // All 3 scenarios will fail with the `'id' of undefined`
          // problem
          // "/*/*/media",
          "/*/*/users",
        ],
      },

PS:我_确实_设法获取的一个 URL 是https://wesbos.com/

快乐更新:通过在查询中包含taxonomies ,我设法使用includedRoutes使其工作(_对于较小的站点),即使使用users和/或media . 现在我没有收到'id' of undefined错误:D

@pieh我相信usersmedia类型依赖于taxonomies ,所以也许只要配置包含这两种类型中的任何一种,它们就应该默认出现? 如果我可以帮助进一步排除故障,请告诉我! 作为结束语,这个taxonomies错误似乎与无限构建过程无关。 对于大于约 500 个媒体文件的站点,我仍然无法完成构建过程!

更新 2 号:所以,我已经设法让它适用于queroinvestiragora.com ,它有 600 个媒体文件,但只有 70 个帖子,在=END PLUGIN===之后大约需要 15 秒,但它有效。 但是, www.clubedospoupadores.com有 702 个媒体文件和 336 个帖子,它不会编译。

PS:我在这些实验中的配置是:

    {
      resolve: 'gatsby-source-wordpress',
      options: {
        baseUrl: "queroinvestiragora.com",
        protocol: "http",
        hostingWPCOM: false,
        useACF: false,
        concurrentRequests: 10, // I've also tried removing it and going with the default, it's the same result
        verboseOutput: true,
        includedRoutes: [
          "/*/*/categories",
          "/*/*/posts",
          "/*/*/pages",
          "/*/*/tags",
          "/*/*/media",
          "/*/*/users",
          "/*/*/taxonomies",
        ],
      },
    },

你好,

我设法使用此处概述的步骤添加跟踪https://www.gatsbyjs.org/docs/performance-tracing/ 。 不幸的是,它没有提供太多信息,因为它只是告诉我源和转换节点确实需要很长时间。

然而,在遇到一些涉及图像的非确定性行为后,我对这个问题进行了一些自己的调试。 在运行开发或构建脚本时,我会遇到一种情况,即并非所有图像都将被下载并且 localFile 节点将无法完成。 在深入研究代码后,我确定这里似乎存在问题

https://github.com/gatsbyjs/gatsby/blob/ad142af473fc8dc8555a5cf23a0dfca42fcbbe90/packages/gatsby-source-wordpress/src/normalize.js#L483 -L506

对我来说 createRemoteFile 节点由于服务器超时错误而失败,并且默认返回 null。 我还必须向 createRemoteFile 节点添加一些日志记录,以确定这一点并获得实际的服务器响应。 由于这些节点不完整且没有 ID,因此它们不会在缓存中注册。 tmp 文件被删除,gatsby-source-filesystem 不完整。 无论出于何种原因(我还没有看过那么远),在再次运行构建脚本时,源文件系统随后被删除,这可能是因为脚本检测到文件系统无效或不完整。 正是这个过程让我创建了一个循环,并在以后的构建中导致错误,因为文件系统永远不会完成。

我正在研究一个修复程序,该修复程序似乎至少可以缓解与大量图像有关的一些问题。 当开发或构建脚本第一次成功下载所有图像时,它随后不会被删除,然后构建过程发生得非常快,因为图像被 gatsby-source-filesystem 正确缓存! 我的构建时间从 15 分钟缩短到 1 分钟。

我不确定这是否与拥有大量帖子的构建有关。 我的问题与下载 1.6 GB 的图像数据直接相关。

这是我第一次使用 gatsby 的源插件,所以如果有人对此有任何想法或建议,我将不胜感激! 我应该能够在今天晚些时候发布我的 repo 我正在努力让它使用我的本地版本的 gatsby-source-filesystem 而不会出现并发症。

你好,

跟进我几天前的评论。 这是我的回购。

https://github.com/njmyers/byalejandradesign.com.git

我在这个项目中使用了 monorepo,所以如果你想在本地运行存储库,这里有一些步骤。

  1. 确保您拥有最新版本的 Yarn 1.12.3
  2. 克隆插件分支git clone https://github.com/njmyers/byalejandradesign.com.git -b wordpress-plugin
  3. 运行yarn && yarn bootstrap
  4. 导航到 gatsby 文件夹,以便您可以查看该文件夹cd packages/web
  5. 运行yarn developyarn build-web 。 它应该在第一次成功完成,随后运行相同的命令将导致更快的构建! 源和转换节点对我来说需要 222 秒,而之前和/或未完成需要 3 倍。
  6. 如果您想查看源代码和转换过程中实际发生的情况,您可以在文件浏览器中查看/packages/web/.cache/gatsby-source-filesystem您将看到文件正在那里创建。

我完全重写了 downloadMediaFiles 函数。 您可以在此链接中看到该文件https://github.com/njmyers/byalejandradesign.com/blob/wordpress-plugin/packages/gatsby-source-wordpress/src/download-media-files.js

它可能比它需要的更冗长,但我必须这样做才能弄清楚正在发生的一切。 我更改的功能是在 createRemoteFileNode 返回 null 时添加承诺拒绝。 然后我使用一个函数 downloadRunner 来限制请求,这样它们就不会一次全部命中服务器,也不会重试承诺拒绝。 我在每个 createRemoteFileNode 请求之间添加了 200 毫秒的限制。 我确信可以调整这个值,其中一些可能更适合直接添加到 createRemoteFileNode。

如果有人好奇 WP 安装是 EC2 微型实例,而映像位于 CloudFront 分发版后面。 就我个人而言,我在获取帖子方面从来没有遇到过任何问题,我的问题是获取图片,我相信人们遇到的大多数问题都是由于这个原因造成的。

另外,如果有人想跟踪或调试他们自己的网站,我建议从这里开始......

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L240 -L244

我在 catch 子句中添加了日志记录,并且能够确定图像节点没有被正确处理,因为我收到超时错误然后返回 null。

@njmyers我只是简单地看了一下,我想如果这行得通,我们应该直接在createRemoteFileNode使用类似的方法。 我们在那里使用queue ,所以这个函数的使用者(在这个例子中是gatsby-source-wordpress )不需要担心这个。 可能有问题的一件事是 200 毫秒的节流 - 也许我们可以在没有它的情况下开始,当我们开始看到问题时会自动应用节流(每个主机名)

@pieh是的,这可能是应用此逻辑的地方。 对我来说,节流是一种解决这个问题并诊断问题的方法,所以我同意createRemoteFileNode应该能够自己处理这个问题。

然而,特别有问题的是当前的行为是默默地失败并返回空值。 在我看来,应该就操作的失败或成功进行一些沟通。 我认为createRemoteFileNode可以通过以下功能变得更加健壮。

1) 急切地建立联系
2) 如果服务器出现错误,则在需要时开始节流和/或重试
3)为节流/重试设置一些合理的默认值
4)创建一个入口点来调整节流/重试
4) 如果由于某种原因无法处理节点,则拒绝承诺。

我也可以说我在这里玩了超时值https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L135 - L141。 尽管这增加了成功响应的可能性,但我仍然必须添加处理以确保成功响应。

这个逻辑的正确入口点很可能就在这里。

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L259 -L269

如果任务失败,它们将被重试和/或失败,然后最终被拒绝。

也只需简要阅读queue文档。 我明白你在说什么queue能够自己管理这个。

@njmyers不错的调查工作! 绝对同意文件下载需要更智能!

实际上将文件下载部分提取到它自己的包中可能会很好,该包专注于下载和缓存远程文件的这个问题。

我们很有可能需要在 Gatsby 和未来的多个地方使用该功能,而且互联网上的其他人也希望使用该功能。

@KyleAMathews你的意思是将createRemoteFileNode提取到一个单独的包中?

不仅仅是文件下载和缓存部分。 然后 createRemoteFileNode 将调用此包并返回一个承诺,该承诺将在下载文件(或从缓存中返回)时解决。

我自己的驾驶舱源插件也有这个问题。

我明白了,这真的更像是将这些部分代码提取到一个单独的包中......

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L125 -L244

这似乎是专门处理下载和缓存的代码,如果我错了,请纠正我。 很高兴为这个工作! 只是想弄清楚它在更大的生态系统中是如何运作的。

只修复 gatsby-source-wordpress 的 PR 会被接受,然后提取修复吗? 按原样使用

@dustinhorton不确定这是否有帮助,但我发现如果您想使用本地插件,最好将 gatsby 直接指向 package.json 文件。 在我开始明确指定它之前,我很难让 gatsby 找到我的本地插件。

https://github.com/njmyers/byalejandradesign.com/blob/d56b1938f6d1bc22c3cf2282bb3198e378fe3561/packages/web/gatsby-config.js#L91 -L94

我仍然很高兴解决这个问题,甚至是讨论的新插件。 只是寻找一些关于如何整合它的指导,因为它似乎是一个破坏性的变化,可能会影响我不知道的许多其他事情。 @KyleAMathews 有什么想法吗? 我仍然觉得好像这里的代码

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L125 -L244

是应该提取到它自己的包中的部分。 话虽如此,它是createRemoteFileNode的核心功能之一,我想确保我正确地执行它,以便它可以正确地集成回生态系统。

@njmyers您的代码选择基本正确 - 我们还希望我们当前的队列(ATM 限制为 200 个并发请求,这对于本地开发人员和 wordpress 似乎不太好)移动并可能更改。

@dustinhorton我认为首先在 wordpress 插件中使用它是合理的(主要是因为它实际上已经完成)。

@pieh非常感谢您的澄清! 我将开始研究一个新插件。

关于临时的 wordpress-source 修复,我唯一的另一个问题是在这里做什么

https://github.com/njmyers/byalejandradesign.com/blob/d56b1938f6d1bc22c3cf2282bb3198e378fe3561/packages/gatsby-source-wordpress/src/download-media-files.js#L169 -L173

目前仍然可能出现网络错误,并且整个 downloadMediaFiles 函数都需要一个 catch 子句。 将错误传递给 gatsby 的正常行为是什么? 我很乐意将该代码添加到 wordpress 插件中,以将网络错误正确传递给正确的处理程序。 也许我们可以显示错误消息和对此问题的引用? 感谢你的协助!

@njmyers谢谢——是的,我正在尽可能地复制你的设置,除了它是一个 monorepo(包括引用package.json )。 运行develop只会出错,就好像没有gatsby-source-wordpress 。 我很快就会再去这里。

更忠实地重建你的 monorepo,奇怪的是它只是坐在source and transform nodes ,就像在降级得到的依赖之前使用非分叉的 gatsby-source-wordpress 一样。

@pieh能够回答他的询问 @ https://github.com/gatsbyjs/gatsby/issues/6654#issuecomment -442536931 吗?

@dustinhorton是的,如果您有很多图像,它也应该在那里放置一段时间。 如果远程文件下载失败,我的 fork 将抛出unhandled promise rejection 。 这就是为什么我希望能够有一些机制来正确处理这种情况。

我想我在另一个线程上也读到了关于集成某种进度管理器的讨论,因为这将提供有关插件状态的反馈。

如果您在 project-root/.cache/gatsby-source-filesystem 下查看操作系统文件系统,您应该能够看到所有正在下载的图像。 就我而言,现在几乎有 400 张图像,因此确实需要一些时间。 然而,在使用我的分叉版本之前,插件会默默地因错误而失败,然后永远不会进步,导致源和转换需要几个小时的问题......

你有回购吗? 我很想能够在另一个站点上尝试它,因为到目前为止我只在我的站点上的现实生活中对其进行了测试。

@njmyers那是规则——如果你不介意,给我发一封电子邮件: [email protected] ,或者只是寻找一个邀请。 今晚我会准备一些东西。

更新got为我解决了所有问题。

got@9的问题在于它需要 Node 8 (https://github.com/sindresorhus/got/releases/tag/v9.0.0),所以我们无法升级 ATM :(

我们至少应该能够升级到got@8 ,但我不确定这是否会解决问题

got@8似乎实现了符合 RFC 7234 的 HTTP 缓存,因此 gatsby-source-filesystem 可以提供它自己的文件系统缓存适配器。 考虑到资源是可缓存的,这至少应该减少第二次在源和转换节点上花费的时间。

嗨!

这个问题已经沉寂了。 诡异的安静。 👻

我们遇到了很多问题,因此我们目前在 30 天不活动后关闭问题。 距离上次更新已经过去了至少 20 天。

如果我们错过了这个问题,或者如果您想保持打开状态,请在此处回复。 您还可以添加标签“not stale”以保持此问题的开放性!

感谢您成为 Gatsby 社区的一员! 💪💜

@gatsbot仍然是一个问题。

被要求为你们所有人贡献一篇博客文章。 不能这样做,因为它卡在源和转换节点上。 看到另一个问题,但我没有看到哪里可以解决这个问题。 它是 gatsbyjs 的一个分支,最新的上游。 我只让它运行一次。 它总是卡在转换节点上。

在构建时无法从几个站点抓取屏幕截图。 我会在早上添加违规网站。

@twhite96我刚刚遇到了这个问题,对我

所以看起来这仍然是一个问题......

使用 gatsby-source-s3 拉出 100 张照片并通过锐化转换它们时面临同样的问题。 有人想出解决办法吗?

不知何故,我的问题得到了解决(随机?)。 这是我采取的步骤,我创建了一个带有较少图片的新 s3 存储桶(用于测试),然后尝试构建,并且非常快速地成功构建。 然后我决定返回并尝试从原始桶中拉出,现在突然间它在 49 秒内成功构建,而最初它会持续数小时。 我不知道仅仅在铲斗链接中切换是如何修复失速的,但希望这有助于有人弄清楚。 也许它与缓存有关?

大家好。 我更新了我用于有此问题的网站的本地插件版本。 我认为这是一个更好的实现,因为它在“createRemoteNode”之前使用“更好的队列”并传入“concurrentRequests”参数。 它有点多余,因为“createRemoteNode”已经使用了一个队列,但不管这个版本似乎与最近的 gatsby 升级一起工作得很好,并提供了关于文件进度的反馈。 我会为此努力争取一个公关。 抱歉耽搁了,我知道我说过我会早点处理这个,但一直很忙!

https://github.com/njmyers/byalejandradesign.com/blob/wordpress-plugin/packages/gatsby-source-wordpress/src/download-media-files.js

@njmyers

非常感谢。 你的版本解决了我遇到的一些问题。 我结合了一两行来过滤掉下载 25 GB 的 mp3,我现在准备好了!

肯定还是个问题。
在过去的 24 小时里,我一直在尝试编译我的项目。 从大约 12 次尝试中,3 次成功输出和实际 WP 连接。 有什么解决办法吗?
顺便说一句,我试过使用插件的@njmyers版本(很棒的工作,实际上!),但结果好坏参半。 有时它会抱怨 wordpress_parent 或 Date 并最终崩溃,但无法弄清楚这些错误的实际情况。 在其他构建中,不同的错误(但它们确实会编译,这很有趣),这实际上会导致 GraphQL 出现问题。

@lucassilvagc你能发布一些输出吗? 我很高兴人们正在尝试和测试分支。 让我们让它更好地工作,以便我们可以打开 PR!

@njmyers当然!

快速概览正在发生的事情:

我的网站目前运行大约 1940 个图像文件,可能是 WordPress 多次创建多个图像文件的错。 如果我确实使用了 vanilla _gatsby-source-wordpress_,问题就会按预期出现(我昨天晚上在另一个构建环境中做了一个“vanilla”构建——它返回了我们在这个问题上讨论的相同问题。这个当所有图像文件返回时,构建工作并编译)。 通过使用您的插件(替换 node_modules/gatsby-source-wordpress 中的所有文件(如果我错了,请纠正我)),_gatsby develop_ 返回以下内容:

TypeError: Cannot read property 'wordpress_parent' of undefined

  - normalize.js:287 entities.map.e
    [amazingtec]/[gatsby-source-wordpress]/normalize.js:287:11

  - Array.map

  - normalize.js:286 Object.exports.mapElementsToParent.entities [as mapElementsToParent]
    [amazingtec]/[gatsby-source-wordpress]/normalize.js:286:12

  - gatsby-node.js:134 Object.exports.sourceNodes
    [amazingtec]/[gatsby-source-wordpress]/gatsby-node.js:134:24


warning The gatsby-source-wordpress plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes — 299.757 s
success building schema — 10.192 s

很快,它输出:

'Cannot query field "allWordpressPage" on type "Query". Did you mean "allSitePage"?',
    locations: [ [Object] ] } ]
error UNHANDLED REJECTION

  TypeError: Cannot read property 'allWordpressPage' of undefined

  - gatsby-node.js:54 graphql.then.result
    C:/Projects/amztec-gtby/amazingtec/gatsby-node.js:54:36

PS:正如我上面所说,这是 gatsby-source-wordpress 的原始版本,通过替换文件_“转换”_ 到您的版本。 我认为它无法查询所有页面的事实与没有生成节点有关。 还需要注意的是,此版本与我的原版版本相同,但在未出现此问题时仍能正常工作。

还要注意,添加路由似乎对我造成了相同的初始问题(因为我想避免不相关的不同页面或由于 WordPress 上的多个保护层而返回错误)。 我只是不知道我列出的路线是否正确,或者之后我是否遗漏了什么。

我对您的回复非常满意,这个问题目前对我的项目来说是一个巨大的挫折,我很高兴您仍然关注这个问题。 非常感谢!

有 400 多个带有 acf 字段和 4000 张图片的自定义帖子也有同样的问题。

我更新了,并且能够在 35 分钟内构建

更新got后无法再次构建

正如预期的那样,因为这个错误仍然存​​在于 gatsby-wordpress 中。 考虑到所有因素(平均互联网速度、处理能力、文件总数等),下载和处理所有图像的 35 分钟一直是一个很长的时间。
您可以尝试根据您的特定用途调整@njmyers版本,它会像下载您拥有的每个图像文件一样有效。

正如预期的那样,因为这个错误仍然存​​在于 gatsby-wordpress 中。 考虑到所有因素(平均互联网速度、处理能力、文件总数等),下载和处理所有图像的 35 分钟一直是一个很长的时间。
您可以尝试根据您的特定用途调整@njmyers版本,它会像下载您拥有的每个图像文件一样有效。

当我有少量图像时,我的网站运行良好,但当我开始添加更多图像时,也会发生这种情况。

@MWalid我如何更新got ? 谢谢。

一整天都在尝试构建,但没有成功。 有大约 1450 张图片。

我们现在已经 2 天无法部署了。 有人可以帮助我指出代码中发生这种情况的正确方向,以便我可以尝试找到解决方案吗?

我们现在已经 2 天无法部署了。 有人可以帮助我指出代码中发生这种情况的正确方向,以便我可以尝试找到解决方案吗?

您是否已将got gatsby-source-filesystemgot嵌套依赖项升级为至少使用版本9.4.0

如果没有,您应该添加:

  "resolutions": {
    "gatsby-source-filesystem/got": "9.4.0"
  }

在 Gatsby 项目的package.json 。 然后删除node_modules和您的yarn.lock文件并再次安装。

注意:此resolutions功能仅适用于yarnnpm还没有实现。

@anagstef非常感谢您的提示! 我会试试这个并报告回来。

运行gatsby develop ,有没有办法在每次启动命令时保留本地缓存而不是获取远程数据?

@anagstef看起来工作好多了! 谢谢你的提示!

使用此版本的 got 构建时,输出非常冗长。 不知道有没有什么办法可以去掉?

@nratter我很高兴它对你

是的,我知道,它非常冗长,无法关闭。 破坏所有有用的控制台输出。

经过一番调查,我认为是这里造成的:
https://github.com/gatsbyjs/gatsby/blob/80c7023a8bc23886939205fe52e305277294e6af/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L155

如您所见,每次downloadProgress事件发出时,它都会调用console.log来显示每个文件的下载进度,这种情况每秒发生太多次。 这在之前不是问题,因为旧的got版本没有实现downloadProgress事件。

也许我们可以通过 PR 修复它? 看起来像调试剩余的代码。

我遇到了同样的问题,停留在“源和转换节点”上。 在大量 console.logs 之后,我的问题最终成为从 wordpress 检索媒体文件的超时问题。 问题不在于服务器无法处理它,而在于 cloudflare 速率限制和在大约 350 个请求后抛出超时。

我绕过了 cloudflare,直接进入了 vps,我不再看到“源和转换节点”,我的构建完成了。

我的解决方法是使用本地 wordpress 进行测试,实时站点在 netlify 中,而部署它并没有导致任何问题。

伙计们,我设法通过串行而不是并行运行createRemoteFileNode请求来解决这个问题。

这是我正在使用的功能:

/**
 * Map over items array using the fn function but wait for each step to finish before moving to the next one
 */
exports.serialMap = async (items, fn) => {
  const results = []
  for (const item of items) {
    const result = await fn(item)
    results.push(result)
  }
  return results
}

这是我如何使用它:

const imageNodes = await serialMap(node.___originalImages, imgUrl => {
  return createRemoteFileNode({
    url: imgUrl,
    parentNodeId: node.id,
    store,
    cache,
    createNode,
    createNodeId,
  })
})

下载图像后,这是我的源和转换步骤的外观

Downloading remote files [==============================] 1063/1063 156.1 secs 100%
Downloading remote files [==============================] 1064/1064 157.2 secs 100%
Downloading remote files [==============================] 1065/1065 158.4 secs 100%
Downloading remote files [==============================] 1066/1066 159.5 secs 100%
Downloading remote files [==============================] 1067/1067 160.5 secs 100%
Downloading remote files [==============================] 1068/1068 161.5 secs 100%
Downloading remote files [==============================] 1069/1069 162.6 secs 100%
Downloading remote files [==============================] 1070/1070 163.7 secs 100%
Downloading remote files [==============================] 1071/1071 164.9 secs 100%
Downloading remote files [==============================] 1072/1072 166.0 secs 100%
Downloading remote files [==============================] 1073/1073 167.5 secs 100%
Downloading remote files [==============================] 1074/1074 169.2 secs 100%
Downloading remote files [==============================] 1075/1075 171.0 secs 100%
success source and transform nodes — 175.271 s

希望它也能解决您的问题。
干杯

@ancashoria我应该把这段代码放在哪里?

@ancashoria是的,我也不清楚在哪里放置此代码。

这与gatsby-source-wordpress插件有些无关。 我的gatsby-node.js有上面的代码。 这个想法是并行触发所有这些请求会导致它们失败,所以我编写了帮助函数来一个接一个地触发它们。

我猜gatsby-source-wordpress也有类似的问题,但我对它不太熟悉。
抱歉,我无法提供更多帮助。

这似乎与大量图像和缓慢的互联网连接有关。 Netlify 能够构建该站点,但我的本地连接不是,因为它的下载速度仅为 1MB/s,这导致它在 30 秒后超时并在大图像上失败。

我有 1gb 光纤,没有“大量”图像。

下载wordpress后,我没有在本地转换博客图片,我只是使用他们的网址。 如果有一个设置可以在这种情况下禁用这些图像的下载,那就太好了。

伙计们,我设法通过串行而不是并行运行 createRemoteFileNode 请求来解决这个问题。

是的,这个问题实际上是基于createRemoteFileNode使用 200 的并发性这一事实,这对于大多数 WP 服务器来说太多了。 我在 CloudFront 上有我的图像并且在那里达到了一些速率限制。

我尝试使用源插件的分支版本解决了一段时间的问题,但问题确实不在gatsby-source-wordpress ,而是在gatsby-source-filesystem 。 理想情况下, createRemoteFileNode函数的使用者将能够在那里传递并发。 然后插件可以在其配置中提供并发选项。 我还是想做个 PR 来解决这个问题!

我一直在使用的解决方案只是一个简单的脚本来修改node_modules的代码。 确实非常脆弱且不理想,但直接修改并发是一种简单的技巧。 使用shelljs所以它应该也适用于 Windows 用户(还没有尝试过)。

#!/usr/bin/env node
const path = require('path');
const shell = require('shelljs');

const FILE_PATH = path.resolve(
  __dirname,
  // add path to your root dir here,
  'node_modules',
  'gatsby-source-filesystem/create-remote-file-node.js'
);

shell.sed('-i', 'concurrent: 200', 'concurrent: 20', FILE_PATH);

我遇到了同样的问题,停留在“源和转换节点”上。 在大量 console.logs 之后,我的问题最终成为从 wordpress 检索媒体文件的超时问题。 问题不在于服务器无法处理它,而在于 cloudflare 速率限制和在大约 350 个请求后抛出超时。

我绕过了 cloudflare,直接进入了 vps,我不再看到“源和转换节点”,我的构建完成了。

这正是我的问题。 Netlify 的构建速度非常快 - 不到 2 分钟。 只有大约 30 个帖子,大约有 500 个源图像。 本地不是每个都完成,只需将 CloudFlare 状态取消为 DNS 即可立即解决问题

我遇到了同样的问题,停留在“源和转换节点”上。 在大量 console.logs 之后,我的问题最终成为从 wordpress 检索媒体文件的超时问题。 问题不在于服务器无法处理它,而在于 cloudflare 速率限制和在大约 350 个请求后抛出超时。
我绕过了 cloudflare,直接进入了 vps,我不再看到“源和转换节点”,我的构建完成了。

这正是我的问题。 Netlify 的构建速度非常快 - 不到 2 分钟。 只有大约 30 个帖子,大约有 500 个源图像。 本地不是每个都完成,只需将 CloudFlare 状态取消为 DNS 即可立即解决问题

我也发现确实如此。 我以前有一个导致构建失败的图像,并认为 Cloudflare 是问题所在。 这个问题最近又回来了,因为@amcc建议不要通过 Cloudflare 路由 A 记录,也立即在本地解决了这个问题。

只是想回应一下,这不仅仅是一个 WP 源问题 - 用gatsby-source-prismic遇到了同样的问题,用@njmyers hack 减少了源文件系统的并发性为我修复了它,所以猜测这是一个速率限制/过载问题。

同意,如果没有别的,源文件系统的并发性应该是可配置的。

@njmyers我很抱歉问这个问题,但是这个修复程序究竟是如何执行的。 只需在构建之前运行脚本,或者我是否需要在构建过程中以某种方式引用该脚本,因为我目前正在问自己如何在本地以及例如 netlify 上应用此修复程序。

@alexanderwe不用担心,无论如何这是一个愚蠢的黑客。 您可以在安装node_modules后运行它。 我不是100%肯定,但我相信postinstall项目中的package.json文件会工作。

对我来说,当我使用包含超过 500 个图像的 json 时,Gatsby 有 50% 的时间挂在“源和转换节点”上。 我正在使用 gatsby-source-custom-api

图像托管在快速、稳定的服务器中。
我的互联网连接也快速而稳定。

"gatsby": "^2.9.4",
"gatsby-image": "^2.1.4",
"gatsby-plugin-emotion": "^4.0.7",
"gatsby-plugin-sharp": "^2.1.5",
"gatsby-plugin-typography": "^2.2.13",
"gatsby-source-custom-api": "^2.0.4",
"gatsby-transformer-remark": "^2.4.0",
"gatsby-transformer-sharp": "^2.1.21",

我能做些什么来调试它?

这个问题只发生在 gatsby-source-custom-api 或 source-wordpress 上?

它也发生在我身上。 我已经尝试了所有建议的修复方法,但似乎没有任何效果。 绝对不会再次使用 Wordpress 作为 Gatsby 的后端,尽管我听说人们在使用其他服务时也遇到了类似的问题。

@alexanderwe解决此问题的正确方法是实施@njmyers 建议的补丁
然后将另一个 PR 引入gatsby-source-wordpress和其他人,以便根据他们在gatsby-config.js引用实际进行配置

@sebastienfi我只是偶然发现了这个https://github.com/gatsbyjs/gatsby/issues/14819#event -2418874313 和相应的提交https://github.com/gatsbyjs/gatsby/commit/90aa24787b32ef9613b6becb92fedab3820000000000000000000000000000000000000000添加了一个环境变量来配置并发率,为我解决了这个问题。 还有一个关于环境变量与配置参数的持续讨论: https :

您是否尝试将GATSBY_CONCURRENT_DOWNLOAD设置为较低的数字? 默认情况下,它设置为 200。

linux/mac:
GATSBY_CONCURRENT_DOWNLOAD=5 gatsby build

视窗:
setx GATSBY_CONCURRENT_DOWNLOAD 5; gatsby build

@wardpeet
我试过了,没有任何改变

它肯定与源文件系统有关,因为日志显示图像已成功检索......问题仍然很大......我们在截止日期前迟到了,我们真的在寻找一个解决这个问题...

将 wordpress 源插件设置为调试后,我看到了这个
image
总是在 470-480 之间挂断……但通常不在同一个地方。

有谁知道这是在代码中执行的位置?

最终通过在中途切换 vpn 使其工作

有没有人愿意与我分享他们的 repo 和凭据,以便我可以尝试一下并尝试找到问题?

请随时通过[email protected]给我发送私人邮件

我的 repo 在这一点上不容易重新创建——我有一个 db 的备份,因为它在某个地方,但为了建立网站,我不得不将每个月的帖子减少到一个帖子中,以保存多年的内容。

@wardpeet通过电子邮件向您发送了我的 repo Ward ([email protected])。 让我知道事情的后续。

我们公司换了wifi,增加了带宽。 今天下载图片没有问题....但我还是不明白,是网络还是并发?

然而,Netlify 上的所有构建都失败了......

下午 5:13:43:=== [获取 wordpress__wp_media] === https://wildkiwi.com/wp-json/wp/v2/media
下午 5:13:43:实体总数:1717
下午 5:13:43:要请求的页面:344
下午 5:13:45:请求失败,错误代码为“未定义”

错误代码未定义,所以我真的不明白发生了什么......

当我将并发请求更改为 5 时,它适用于 Netlify

我在使用不同的插件(https://github.com/angeloashmore/gatsby-source-prismic)时遇到了这个问题,设置GATSBY_CONCURRENT_DOWNLOAD=50就解决了这个问题。

这只是突然发生的(有一天我的网站会建立,下一天它不会,没有任何更改),并且没有任何错误消息,为客户部署网站而没有信心这有点令人不安不会再发生了。

我们基本上一次下载 200 个图像,但这对于某些计算机/互联网连接可能会有问题。 一个好的解决方案是烘焙一些重试机制。

我遇到了这些问题,但我设法通过使用https://免费版本的setx GATSBY_CONCURRENT_DOWNLOAD 5; gatsby build和 Smushing 所有图像(其中一些尺寸和文件大小过大)的组合使构建工作正常en-gb.wordpress.org/plugins/wp-smushit/。

你好! 我正在创建的源插件(与 WordPress 无关)遇到了同样的问题,当从 API 下载 1000 多个图像时。 它几乎总是在进程结束时挂起。

设置GATSBY_CONCURRENT_DOWNLOAD并没有解决它。 我试过50205 ,没有运气。

我从 API 获得了一组尺寸,我使用的是最大的图像,但将其更改为最小的图像并且也没有修复它。

在这一点上很难确定为什么它会失败,我唯一得到的是source and transform nodes然后永远保持沉默。

如果有一个调试机制,那就太棒了。

我在 gatsby+wordress 集成中遇到了同样的问题。 在我使用 createRemoteFileNode 的 onCreateNode API 中,构建将永远停止。

解决方案:我将 gatsby-source-filesystem 从 2.0.4 更新到 2.1.8,并将 GATSBY_CONCURRENT_DOWNLOAD=50 添加到我的环境变量中。

你好👋

我的项目有类似的问题。

环境

  System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.17.3 - ~/.yarn/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 2.7.15 - /usr/local/bin/python
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 68.0.1
    Safari: 12.1.2
  npmPackages:
    gatsby: ^2.13.42 => 2.13.42
    gatsby-cli: ^2.7.34 => 2.7.34
    gatsby-image: ^2.2.14 => 2.2.14
    gatsby-plugin-glamor: ^2.1.3 => 2.1.3
    gatsby-plugin-manifest: ^2.2.4 => 2.2.4
    gatsby-plugin-offline: ^2.2.4 => 2.2.4
    gatsby-plugin-react-helmet: ^3.1.5 => 3.1.5
    gatsby-plugin-sass: ^2.1.10 => 2.1.10
    gatsby-plugin-sharp: ^2.2.9 => 2.2.9
    gatsby-plugin-svg-sprite: ^2.0.1 => 2.0.1
    gatsby-source-filesystem: ^2.1.18 => 2.1.18
    gatsby-source-wordpress: ^3.1.12 => 3.1.12
    gatsby-transformer-sharp: ^2.2.5 => 2.2.5

我的 WP 网站上有 80000 多个媒体。 当我运行npx gatsby develop我被困在“END PLUGIN”之后。

...
=== [ Fetching wordpress__TAG ] === https://[WP_REST_API]/wp-json/wp/v2/tags

Total entities : 8805
Pages to be requested : 89
 -> wordpress__TAG fetched : 8805
Fetching the wordpress__TAG took: 12408.827ms
⠀
=== [ Fetching wordpress__wp_partners ] === https://[WP_REST_API]/wp-json/wp/v2/partners
 -> wordpress__wp_partners fetched : 22
Fetching the wordpress__wp_partners took: 1268.292ms
⠀
=END PLUGIN=====================================: 377120.512ms
⠼ source and transform nodes

我试图修改 GATSBY_CONCURRENT_DOWNLOAD 值,但没有任何改变。
有没有办法限制媒体数量导入? 例如 :

{
  resolve: `gatsby-source-filesystem`,
  options: {
    name: `images`,
    path: `${__dirname}/src/images/uploads`,
    limit: 50,
  },
},

同样的问题,我的自托管 WP 有 1690 个媒体,我总是卡在下载远程文件步骤的末尾,有时只缺少一个媒体...

编辑:这次构建成功GATSBY_CONCURRENT_DOWNLOAD=5 yarn build ...

@kvalium感谢您的评论, GATSBY_CONCURRENT_DOWNLOAD=5 yarn build为我工作

我遇到了同样的问题,我设法通过调整终端窗口的大小来解决这个问题。

请参阅关于 #4666 的最新评论。

我也有同样的问题。 我解决了它:

rm -r node_modules/ 
rm -r .cache
sudo chown -R login:login . 
fuser -k 8000/tcp 
yarn 
gatsby build
gatsby develop

希望它可以帮助

看起来这是一个古怪的问题。 这是我的经验:

  • ❌ 我在 macOS High Sierra 上看到了这个问题(使用 iTerm)
  • ✅ 我开始使用GATSBY_CONCURRENT_DOWNLOAD=50 gatsby develop并且问题消失了(这种情况持续了几个星期)
  • ❌ 我升级到 Mojave 并将我的全局 Gatsby 安装升级到2.7.47 ,然后又开始看到这个问题(使用 iTerm)
  • ❌ 尝试将GATSBY_CONCURRENT_DOWNLOAD更改为 5
  • ❌ 试着吹走.cachenode_modules
  • ❌ 尝试在运行gatsby develop时调整 iTerm 窗口的大小(50 和 5)
  • ❌ 在“终端”应用程序中运行GATSBY_CONCURRENT_DOWNLOAD=50 gatsby develop ,而不是在 iTerm
  • ✅ 两周后尝试在 iTerm 中使用GATSBY_CONCURRENT_DOWNLOAD=50 gatsby develop并在此过程中多次调整窗口大小,并且成功了。

过早地认为我让它与最后一个一起运行,但后来它挂了。 希望这对其他人有帮助。 这似乎仍然没有完全确定,但我们正在缓慢但肯定地到达那里。

更新:今天这对我有用。 不确定是因为我在过程中的正确点调整了 iTerm 窗口的大小,还是因为我看到它从 93% 一直到 100%,但这次有所不同。

除了使用 GATSBY_CONCURRENT_DOWNLOAD = 5,将以下代码添加到您的 gatsby-node.js 文件中

// 国际化
export.onPostBuild = () => {
ChildProcess.execSync("ps aux | grep jest | grep -v grep | awk '{print $2}' | xargs kill")
console.log('复制语言环境')
fs.copySync(path.join(__dirname, '/src/locales'), path.join(__dirname, '/public/locales))
}

532314892 @bradydowling

不确定是不是因为我在正确的位置调整了 iTerm 窗口的大小

在遇到同样的问题时,我调整了 iTerm 窗口和 bam 的大小——它也突然继续。 不知道这是天方夜谭,还是……

@bradydowling @davegregg哇,这是一个奇怪的。 调整我的 iTerm 窗口大小可以解决问题。

@TylerBarnes不管这是什么,我建议它不是特定于 Wordpress 的。 我没有使用任何与 Wordpress 相关的东西。

@beauhankins你呢?

@davegregg @beauhankins @bradydowling你们中的任何人都可以分享发生这种情况的回购吗? 调整终端窗口的大小解决了这个问题,这看起来真的很奇怪。

@TylerBarnes这是我看到仓库。 我有一点点没碰它。


旁注:您如何处理使用比 CLI 当前安装的版本旧的 Gatsby 克隆 Gatsby 站点的情况?

我在 VS 代码终端中运行命令(我使用 bash)。 它花费了很长时间,正如上面所建议的,我退出了全屏模式并且它起作用了。

@bradydowling感谢分享您的回购! 要使用比 cli 旧版本的 Gatsby,您可以制作一个 npm 脚本来进行开发和构建。

{
  "scripts": {
    "develop": "gatsby develop",
    "build": "gatsby build"
  }
} 

然后运行npm run developyarn develop将使用您项目中的本地版本。

我们正在调查这个问题,但与此同时,任何有问题的人都可以通过运行CI=1 yarn build来解决它,因为这应该在幕后使用不同的记者库。 如果您尝试这样做并且有效,请告诉我们!

@达斯汀霍顿

v2 版本 @ https://github.com/dustinhorton/gatsby-v2-issue。 此时已经构建了大约 50 分钟。

嗯。 我意识到这是大约一年前发布的,从那时起盖茨比发生了很大变化。 在我的机器上运行它时(并在 package.json 中将 gatsby 版本设置为 *),构建似乎在大约 2000 秒(~33 分钟)内完成。
此外,在升级 cli 时,现在有一个进度条,它在“感觉”多长时间方面产生巨大差异,因为您获得了更具体的反馈循环。

采购步骤几乎花费了所有时间(1968 / 1975 秒)。 远程文件的下载是其中的大部分(1845 秒)。

当我查看到此服务器的单次往返时,这并不让我感到惊讶:

# Starting requestInQueue, _concurrentRequests= 10
@ requestInQueue for 75 tasks { concurrent: 10 } { id: 'url' }
@ Fetch http://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media?per_page=100&page=4: 2587.339ms
@ Fetch http://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media?per_page=100&page=10: 2661.584ms
@ Fetch http://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media?per_page=100&page=8: 2695.937ms
@ Fetch http://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media?per_page=100&page=2: 2738.339ms
@ Fetch http://dustinhorton.com/gatsby-wp/wp-json/wp/v2/media?per_page=100&page=6: 2853.199ms

每个请求大约需要 2 到 4 秒。 探索时最初获取的 75 个页面总共需要 18 秒(!)。 我有一个快速的连接,我可以用一个普通的 wget 重现那个时间。

所以最长的一步会尝试下载大约7500个资源。 考虑到单个请求需要 2 到 4 秒,我对它需要这么长时间并不感到惊讶。

即便如此,我确实注意到在 1845 秒的主要下载期间出现了一些暂停。 我不确定这是否只是服务器限制数据(我确实将并发设置为 5)。

我确实尝试过调整终端的宽度(我在 xfce linux,fwiw 上),虽然这偶尔与向前推进的进展相吻合,但我现在确信这更像是巧合而不是因果关系。

底线:虽然我可以重现缓慢的下载和看似“卡住”的进度,但目前所有迹象都表明这几乎是由于等待服务器响应造成的。 此外,终端的宽度似乎对此没有影响。

也就是说:在以非常特定的宽度更新进度条时,终端输出可能会以某种方式卡住。 虽然这不太可能,但并非不可能。 因此我们真的需要一个我们可以自己运行的复制品(所以没有身份验证)。 最好_不_依赖于远程服务器,因为我不想锤击服务器。

我将相应地更新有关此问题的标签。

@njmyers 在https://github.com/gatsbyjs/gatsby/issues/6654#issuecomment -438667221 中发布的repro不再存在

在公布回购https://github.com/gatsbyjs/gatsby/issues/6654#issuecomment通过@bradydowling -562607399要求一堆权限,我没有的,而且似乎有往返时间类似的问题

@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=7: 25025.257ms
@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=4: 27791.269ms
@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=2: 37817.874ms
@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=5: 38056.989ms
@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=3: 38446.504ms
@ Fetch http://topazandsapphire.com/wp-json/wp/v2/media?per_page=100&page=6: 43799.842ms

除了微调器和偶尔的步骤被记录之外,这个采购步骤并没有真正显示任何进度指示器,并且仍然需要几分钟,所以如果有意义的话,也许我们至少可以显示某种进度指示器。

此外,也许它可以帮助指出获取资源的平均时间,因为这表明了为什么“Gatsby”很慢,而它实际上是由往返造​​成的。

在这个 repo 中,即使下载 589 个远程文件也需要大约 5 分钟,进度条经常无缘无故地卡住。

在引导程序之后,由于文件丢失,构建对我来说失败了。

@pvdz我将不得不再次玩这个(我放弃了一段时间)但有些文件即使成功构建也会引发权限问题,所以我认为这些可以忽略。

但是总结一下您的帖子,您是说某些(下载)步骤需要很长时间,我们应该等待更长时间才能完成吗?

@bradydowling嗯,看起来像,是的。 :)

FTR:我对资源收集进行了一些跟踪。 阐明时间安排;

Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6084.jpg: 15605.630ms
Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6036.jpg
Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6051.jpg: 6447.272ms
Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6034.jpg
Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6045.jpg: 6944.355ms
Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6029.jpg
Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6036.jpg: 6401.541ms
Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/01/IMG_6027.jpg

顺便说一句,这些是 6mb 文件。 我使用的是 250Mbs 的连接,可以很好地处理比 1mbs 更快的连接,但它会增加下载时间并不让我感到惊讶。 再多的 cli 大小调整也无法加快速度;)

有趣的。 这只是一个托管在 EC2 上的标准 WordPress 个人博客,所以它不像是一个巨大的安装。 也许这是因为所有这些请求都使主机过载。 或者,我不是 WordPress 专家,但也许对 REST API 调用存在某种标准的 WP 速率限制可能发生? 我还假设这种行为不是本网站独有的。

也许这是因为所有这些请求都使主机过载。

这是我的猜测(或在这个范围内的东西)。 但我正在探索一些我们自己的架构,以检查我们是否因抽象而失去效率。 但考虑到我可以模仿大多数用普通 wgets/curls 报告的时间,我怀疑那里有很多。

所以后来我用一个愚蠢的原始下载器替换了got.stream()位:

    let r = ""
    require("http").get(url, res =>
      res
        .on("data", m => (r += m))
        .on("end", () => {
          console.timeEnd("$$ Fetch time for " + url)
          resolve(r)
        })
    )
$ Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/05/IMG_5260.jpg
$$ Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/09/TRAVEL-LEISURE-2-copy.png: 1003.535ms
$ Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/05/International-Travel-Topaz-Sapphire.png
$$ Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/09/IMG_4606.jpg: 3174.126ms
$ Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/05/Brunch-Topaz-Sapphire-2.png
$$ Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/09/IMG_4647.jpg: 9521.157ms
$ Started actually fetching http://topazandsapphire.com/wp-content/uploads/2016/05/IMG_6978.jpg
$$ Fetch time for http://topazandsapphire.com/wp-content/uploads/2016/05/International-Travel-Topaz-Sapphire.png: 3611.910ms

所以是的,我很确定长时间的延迟(至少在这种情况下)是由下载引起的。 所以也许我们最好的办法是在等待下载时改进反馈:)

很多人说终端窗口调整大小(无论出于什么奇怪的原因)解决了卡在“源和转换节点”上的开发过程。

遗憾的是,当使用 WSL 时,这不是解决方案。 在构建和开发中都卡在本地的“源和转换节点”上。 Netlify 构建确实有效,但本地开发已变得不可能。

@Vacilando您能否调试一些在采购期间为您的站点下载的链接,并手动测试它们是否快速下载? 就像我上面提到的,我看到的一个大问题是某些 wp 主机只是超级慢。

所以如果主机很慢并且有很多内容要下载,那么这一步会花费很多时间,因为这就是这一步应该做的全部; 发现内容并下载它:)

如果您已确认内容本身是在整个步骤的一小部分下载的,请在此处圈回。 在这种情况下,重现将非常有帮助:)

也许在理想的世界中,您可以向 gatsby 传递一个标志,该标志将缓存
站点资产下载,因此不必重复执行此操作。

另一个最佳解决方案是允许设置某种类型的标志
限制下载资产的速率或节流,使其不会崩溃
主人。

对这两个想法有什么想法吗?

2019 年 12 月 19 日星期四下午 6:09 Peter van der Zee通知@ github.com
写道:

@Vacilando https://github.com/Vacilando你能调试一些链接吗
在手动采购和测试期间正在为您的站点下载
他们是否下载快? 就像我上面提到的,我遇到了一个大问题
看到的是某些 wp 主机只是超级慢。

所以如果主机很慢并且有很多内容要下载,那么是的
这一步需要很多时间,因为这就是它应该做的全部
这一步; 发现内容并下载它:)

如果您已确认内容本身只下载了一小部分
整个步骤,请绕回这里。 在这种情况下,repro 将是
非常有帮助:)


你收到这个是因为你被提到了。
直接回复本邮件,在GitHub上查看
https://github.com/gatsbyjs/gatsby/issues/6654?email_source=notifications&email_token=ABS4AU62367MTEWP7LJXWTLQZP5L5A5CNFSM4FLHT3T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBWZGOZLENP6WWW6Z0000076WWW700000076WWWSGO2HPL65HW77HW7HW7HWTL6
或取消订阅
https://github.com/notifications/unsubscribe-auth/ABS4AU7GCV4YMZQH6R37BSDQZP5L5ANCNFSM4FLHT3TQ
.

@bradydowling 的一部分实际上已经存在。 您可以设置环境变量GATSBY_CONCURRENT_DOWNLOAD来配置并发请求的限制。 gatsby-source-wordpress https://github.com/gatsbyjs/gatsby/issues/19292的下一个主要版本将对媒体文件的下载方式有更多的控制。 至于缓存,下载的文件当前已缓存,但是当您更改 gatsby-*.js 文件时,它当前会清除缓存以防止陈旧的缓存导致意外错误。 所以这是一个核心问题,而不是特定于gatsby-source-wordpress ,但一直在努力改进 Gatsby 的缓存。

Partially Jobs Api (#19831) 应该可以解决这个缓存问题。

是的,我看到GATSBY_CONCURRENT_DOWNLOAD更接近顶部。 根据我的经验,这并没有帮助,所以我想我的建议是更细粒度的控制,比如 mb per s/m/h 或类似的东西。 也许我只是在说废话。

@bradydowling我正在考虑添加带有指数退避的请求重试,以及为每秒最大请求数添加一个可选设置,以应对效果不佳的情况。

嗨!

这个问题已经沉寂了。 诡异的安静。 👻

我们遇到了很多问题,因此我们目前在 30 天不活动后关闭问题。 距离上次更新已经过去了至少 20 天。
如果我们错过了这个问题,或者如果您想保持打开状态,请在此处回复。 您还可以添加标签“not stale”以保持此问题的开放性!
友情提示:查看此问题或任何其他问题的最佳方法是打开一个拉取请求。 查看gatsby.dev/contribute以获取有关打开 PR、分类问题和贡献的更多信息!

感谢您成为 Gatsby 社区的一员! 💪💜

我现在要关闭这个。

如果您认为您有 wordpress 采购问题,请先确认您的延迟不是由缓慢的 wordpress 服务器造成的。 然后请打开一个 _new_ 问题(但请随时指出这个问题)。

大量的评论使得跟踪讨论变得非常困难。 因此,打开一个新问题更有可能导致您的特定问题得到答案。

我和其他人在过去一年半的时间里证实了这一点。 我最初的问题是在一个经过良好调整的 vps 上。 @njmyers有一个可能的修复,或者至少是改进,但无法从维护者那里得到任何关于他们希望如何完成的答案。

我想关闭自己,但我认为它需要在那里作为一个警告,即一个中等规模的 wordpress 站点目前还不适合 gatsby。

@dustinhorton我明白。 这个问题已经一年半多了,事情变化很快。 由于这个问题有这么多评论,很难再找出实际问题。

image

Fwiw,如上所述,我检查了上次报告的重现并确定那些至少是由慢速遥控器引起的。 如果您在快速遥控器上有当前 Gatsby 版本的复制品,请告诉我,即使它可能已经发布在此线程中。 或者,如果你想更多地关注它,也许会为它打开一个新问题(并标记我),我会把它留给你:)

(_为了清楚起见,我们关闭了这个问题,因为它已经因为过多的偏离主题的消息而变得有点陈旧,请不要觉得我们在压制讨论,因为这不是我们的意图,我们认识到我们的工作还没有在这里完成!_)

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

benstr picture benstr  ·  3评论

kalinchernev picture kalinchernev  ·  3评论

hobochild picture hobochild  ·  3评论

jimfilippou picture jimfilippou  ·  3评论

rossPatton picture rossPatton  ·  3评论