10000 fix(gatsby-source-drupal): Add timeout in case of stalled API request… · gatsbyjs/gatsby@4722a0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4722a0d

Browse files
GatsbyJS BotKyleAMathews
andauthored
fix(gatsby-source-drupal): Add timeout in case of stalled API requests (#33668) (#33705)
* feat(gatsby-source-drupal): More ports from customer fixes * cleanups (cherry picked from commit 113ae43) Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
1 parent 857a628 commit 4722a0d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

packages/gatsby-source-drupal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Source plugin for pulling data (including images) into Gatsby from Drupal sites.
44

5-
Pulls data from Drupal 8 sites with the
5+
It pulls data from Drupal 8 sites with the
66
[Drupal JSONAPI module](https://www.drupal.org/project/jsonapi) installed.
77

88
An example site built with the headless Drupal distro

packages/gatsby-source-drupal/src/gatsby-node.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ async function worker([url, options]) {
6464
const response = await got(url, {
6565
agent,
6666
cache: false,
67+
timeout: {
68+
// Occasionally requests to Drupal stall. Set a 15s timeout to retry in this case.
69+
request: 15000,
70+
},
6771
// request: http2wrapper.auto,
6872
// http2: true,
6973
...options,
@@ -259,7 +263,7 @@ ${JSON.stringify(webhookBody, null, 4)}`
259263

260264
// lastFetched isn't set so do a full rebuild.
261265
if (!lastFetched) {
262-
setPluginStatus({ lastFetched: new Date().getTime() })
266+
setPluginStatus({ lastFetched: Math.floor(new Date().getTime() / 1000) })
263267
requireFullRebuild = true
264268
} else {
265269
const drupalFetchIncrementalActivity = reporter.activityTimer(
@@ -272,7 +276,11 @@ ${JSON.stringify(webhookBody, null, 4)}`
272276
try {
273277
// Hit fastbuilds endpoint with the lastFetched date.
274278
const res = await requestQueue.push([
275-
urlJoin(baseUrl, `gatsby-fastbuilds/sync/`, lastFetched.toString()),
279+
urlJoin(
280+
baseUrl,
281+
`gatsby-fastbuilds/sync/`,
282+
Math.floor(lastFetched).toString()
283+
),
276284
{
277285
username: basicAuth.username,
278286
password: basicAuth.password,

packages/gatsby-source-drupal/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ ${JSON.stringify(nodeToUpdate, null, 4)}
364364
node.internal.contentDigest = createContentDigest(node)
365365
createNode(node)
366366
reporter.log(
367-
`Updated Gatsby node: id: ${node.id} type: ${node.internal.type}`
367+
`Updated Gatsby nodeid: ${node.id} type: ${node.internal.type}`
368368
)
369369
}
370370
}

0 commit comments

Comments
 (0)
0