Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: gatsby@4.1.2
Choose a base ref
...
head repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: gatsby@4.1.3
Choose a head ref
  • 3 commits
  • 34 files changed
  • 5 contributors

Commits on Nov 10, 2021

  1. feat(gatsby-core-utils): Add retry on HTTP status codes to `fetchRemo…

    …teFile` (#33461) (#33925)
    
    Co-authored-by: Ward Peeters <ward@coding-tech.com>
    Co-authored-by: Benedikt Rötsch <axe312ger@users.noreply.github.com>
    3 people authored Nov 10, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    62a5612 View commit details
  2. fix(gatsby-source-drupal): Ensure all new nodes are created before cr…

    …eating relationships (#33864) (#33926)
    
    Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
    GatsbyJS Bot and KyleAMathews authored Nov 10, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cdeff78 View commit details
  3. chore(release): Publish

     - babel-plugin-remove-graphql-queries@4.1.1
     - babel-preset-gatsby@2.1.1
     - gatsby-cli@4.1.2
     - gatsby-core-utils@3.1.1
     - gatsby-page-utils@2.1.1
     - gatsby-plugin-benchmark-reporting@2.1.1
     - gatsby-plugin-gatsby-cloud@4.1.1
     - gatsby-plugin-image@2.1.1
     - gatsby-plugin-manifest@4.1.2
     - gatsby-plugin-mdx@3.1.2
     - gatsby-plugin-offline@5.1.2
     - gatsby-plugin-page-creator@4.1.2
     - gatsby-plugin-preload-fonts@3.1.1
     - gatsby-plugin-sharp@4.1.2
     - gatsby-plugin-typescript@4.1.1
     - gatsby-recipes@1.1.1
     - gatsby-remark-images@6.1.2
     - gatsby-source-contentful@6.1.2
     - gatsby-source-drupal@5.1.2
     - gatsby-source-filesystem@4.1.1
     - gatsby-source-graphql@4.1.1
     - gatsby-source-shopify@6.1.2
     - gatsby-source-wordpress@6.1.1
     - gatsby-telemetry@3.1.1
     - gatsby-transformer-remark@5.1.2
     - gatsby-transformer-sqip@4.1.2
     - gatsby@4.1.3
    LekoArts committed Nov 10, 2021
    Copy the full SHA
    c3c6970 View commit details
Showing with 526 additions and 95 deletions.
  1. +2 −2 packages/babel-plugin-remove-graphql-queries/package.json
  2. +2 −2 packages/babel-preset-gatsby/package.json
  3. +4 −4 packages/gatsby-cli/package.json
  4. +1 −1 packages/gatsby-core-utils/package.json
  5. +146 −15 packages/gatsby-core-utils/src/__tests__/fetch-remote-file.js
  6. +92 −6 packages/gatsby-core-utils/src/fetch-remote-file.ts
  7. +2 −2 packages/gatsby-page-utils/package.json
  8. +2 −2 packages/gatsby-plugin-benchmark-reporting/package.json
  9. +3 −3 packages/gatsby-plugin-gatsby-cloud/package.json
  10. +3 −3 packages/gatsby-plugin-image/package.json
  11. +2 −2 packages/gatsby-plugin-manifest/package.json
  12. +2 −2 packages/gatsby-plugin-mdx/package.json
  13. +2 −2 packages/gatsby-plugin-offline/package.json
  14. +4 −4 packages/gatsby-plugin-page-creator/package.json
  15. +2 −2 packages/gatsby-plugin-preload-fonts/package.json
  16. +4 −4 packages/gatsby-plugin-sharp/package.json
  17. +2 −2 packages/gatsby-plugin-typescript/package.json
  18. +3 −3 packages/gatsby-recipes/package.json
  19. +2 −2 packages/gatsby-remark-images/package.json
  20. +3 −3 packages/gatsby-source-contentful/package.json
  21. +2 −2 packages/gatsby-source-drupal/package.json
  22. +63 −0 packages/gatsby-source-drupal/src/__tests__/fixtures/1593545806.json
  23. +45 −0 packages/gatsby-source-drupal/src/__tests__/fixtures/webhook-body-multiple-nodes.json
  24. +24 −0 packages/gatsby-source-drupal/src/__tests__/index.js
  25. +37 −0 packages/gatsby-source-drupal/src/gatsby-node.js
  26. +45 −0 packages/gatsby-source-drupal/src/utils.js
  27. +2 −2 packages/gatsby-source-filesystem/package.json
  28. +2 −2 packages/gatsby-source-graphql/package.json
  29. +4 −4 packages/gatsby-source-shopify/package.json
  30. +5 −5 packages/gatsby-source-wordpress/package.json
  31. +2 −2 packages/gatsby-telemetry/package.json
  32. +2 −2 packages/gatsby-transformer-remark/package.json
  33. +2 −2 packages/gatsby-transformer-sqip/package.json
  34. +8 −8 packages/gatsby/package.json
4 changes: 2 additions & 2 deletions packages/babel-plugin-remove-graphql-queries/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remove-graphql-queries",
"version": "4.1.0",
"version": "4.1.1",
"author": "Jason Quense <monastic.panic@gmail.com>",
"repository": {
"type": "git",
@@ -10,7 +10,7 @@
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/babel-plugin-remove-graphql-queries#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"gatsby-core-utils": "^3.1.0"
"gatsby-core-utils": "^3.1.1"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
4 changes: 2 additions & 2 deletions packages/babel-preset-gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-gatsby",
"version": "2.1.0",
"version": "2.1.1",
"author": "Philipp Spiess <hello@philippspiess.com>",
"repository": {
"type": "git",
@@ -22,7 +22,7 @@
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-macros": "^2.8.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"gatsby-core-utils": "^3.1.0",
"gatsby-core-utils": "^3.1.1",
"gatsby-legacy-polyfills": "^2.1.0"
},
"peerDependencies": {
8 changes: 4 additions & 4 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-cli",
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands",
"version": "4.1.1",
"version": "4.1.2",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "cli.js"
@@ -25,9 +25,9 @@
"execa": "^5.1.1",
"fs-exists-cached": "^1.0.0",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "^3.1.0",
"gatsby-recipes": "^1.1.0",
"gatsby-telemetry": "^3.1.0",
"gatsby-core-utils": "^3.1.1",
"gatsby-recipes": "^1.1.1",
"gatsby-telemetry": "^3.1.1",
"hosted-git-info": "^3.0.8",
"is-valid-path": "^0.1.1",
"joi": "^17.4.2",
2 changes: 1 addition & 1 deletion packages/gatsby-core-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-core-utils",
"version": "3.1.0",
"version": "3.1.1",
"description": "A collection of gatsby utils used in different gatsby packages",
"keywords": [
"gatsby",
161 changes: 146 additions & 15 deletions packages/gatsby-core-utils/src/__tests__/fetch-remote-file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check

import path from "path"
import zlib from "zlib"
import os from "os"
@@ -77,6 +78,8 @@ async function getFileContent(file, req, options = {}) {
}
}

let attempts503 = 0

const server = setupServer(
rest.get(`http://external.com/logo.svg`, async (req, res, ctx) => {
const { content, contentLength } = await getFileContent(
@@ -140,7 +143,44 @@ const server = setupServer(
ctx.status(500),
ctx.body(content)
)
})
}),
rest.get(`http://external.com/503-twice.svg`, async (req, res, ctx) => {
const errorContent = `Server error`
attempts503++

if (attempts503 < 3) {
return res(
ctx.set(`Content-Type`, `text/html`),
ctx.set(`Content-Length`, String(errorContent.length)),
ctx.status(503),
ctx.body(errorContent)
)
}

const { content, contentLength } = await getFileContent(
path.join(__dirname, `./fixtures/gatsby-logo.svg`),
req
)

return res(
ctx.set(`Content-Type`, `image/svg+xml`),
ctx.set(`Content-Length`, contentLength),
ctx.status(200),
ctx.body(content)
)
}),
rest.get(`http://external.com/503-forever.svg`, async (req, res, ctx) => {
const errorContent = `Server error`
return res(
ctx.set(`Content-Type`, `text/html`),
ctx.set(`Content-Length`, String(errorContent.length)),
ctx.status(503),
ctx.body(errorContent)
)
}),
rest.get(`http://external.com/network-error.svg`, (req, res) =>
res.networkError(`ECONNREFUSED`)
)
)

function getFetchInWorkerContext(workerId) {
@@ -205,6 +245,10 @@ describe(`fetch-remote-file`, () => {
})
})

afterEach(() => {
jest.useRealTimers()
})

it(`downloads and create a file`, async () => {
const filePath = await fetchRemoteFile({
url: `http://external.com/logo.svg`,
@@ -304,8 +348,6 @@ describe(`fetch-remote-file`, () => {
jest.runAllTimers()
await requests[0]

jest.useRealTimers()

// we still expect 2 fetches because cache can't save fast enough
expect(gotStream).toBeCalledTimes(2)
expect(fsMove).toBeCalledTimes(1)
@@ -365,18 +407,12 @@ describe(`fetch-remote-file`, () => {
jest.runAllTimers()
await requests[0]

jest.useRealTimers()

// we still expect 4 fetches because cache can't save fast enough
expect(gotStream).toBeCalledTimes(4)
expect(fsMove).toBeCalledTimes(2)
})

it(`doesn't keep lock when file download failed`, async () => {
// we don't want to wait for polling to finish
jest.useFakeTimers()
jest.runAllTimers()

const cacheInternals = new Map()
const workerCache = {
get(key) {
@@ -398,18 +434,14 @@ describe(`fetch-remote-file`, () => {
})
).rejects.toThrow()

jest.runAllTimers()

await expect(
fetchRemoteFileInstanceTwo({
url: `http://external.com/500.jpg`,
cache: workerCache,
})
).rejects.toThrow()

jest.useRealTimers()

expect(gotStream).toBeCalledTimes(1)
expect(gotStream).toBeCalledTimes(3)
expect(fsMove).toBeCalledTimes(0)
})

@@ -428,7 +460,30 @@ describe(`fetch-remote-file`, () => {
url: `http://external.com/500.jpg`,
cache,
})
).rejects.toThrow(`Response code 500 (Internal Server Error)`)
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Unable to fetch:
http://external.com/500.jpg
---
Reason: Response code 500 (Internal Server Error)
---
Fetch details:
{
\\"attempt\\": 3,
\\"method\\": \\"GET\\",
\\"responseStatusCode\\": 500,
\\"responseStatusMessage\\": \\"Internal Server Error\\",
\\"requestHeaders\\": {
\\"user-agent\\": \\"got (https://github.com/sindresorhus/got)\\",
\\"accept-encoding\\": \\"gzip, deflate, br\\"
},
\\"responseHeaders\\": {
\\"x-powered-by\\": \\"msw\\",
\\"content-length\\": \\"12\\",
\\"content-type\\": \\"text/html\\"
}
}
---"
`)
})

describe(`retries the download`, () => {
@@ -457,5 +512,81 @@ describe(`fetch-remote-file`, () => {
)
expect(gotStream).toBeCalledTimes(2)
})

it(`Retries when server returns 503 error till server returns 200`, async () => {
const fetchRemoteFileInstance = fetchRemoteFile({
url: `http://external.com/503-twice.svg`,
cache,
})

const filePath = await fetchRemoteFileInstance

expect(path.basename(filePath)).toBe(`503-twice.svg`)
expect(getFileSize(filePath)).resolves.toBe(
await getFileSize(path.join(__dirname, `./fixtures/gatsby-logo.svg`))
)
expect(gotStream).toBeCalledTimes(3)
})

it(`Stops retry when maximum attempts is reached`, async () => {
await expect(
fetchRemoteFile({
url: `http://external.com/503-forever.svg`,
cache,
})
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Unable to fetch:
http://external.com/503-forever.svg
---
Reason: Response code 503 (Service Unavailable)
---
Fetch details:
{
\\"attempt\\": 3,
\\"method\\": \\"GET\\",
\\"responseStatusCode\\": 503,
\\"responseStatusMessage\\": \\"Service Unavailable\\",
\\"requestHeaders\\": {
\\"user-agent\\": \\"got (https://github.com/sindresorhus/got)\\",
\\"accept-encoding\\": \\"gzip, deflate, br\\"
},
\\"responseHeaders\\": {
\\"x-powered-by\\": \\"msw\\",
\\"content-length\\": \\"12\\",
\\"content-type\\": \\"text/html\\"
}
}
---"
`)

expect(gotStream).toBeCalledTimes(3)
})
// @todo retry on network errors
it(`Retries on network errors`, async () => {
await expect(
fetchRemoteFile({
url: `http://external.com/network-error.svg`,
cache,
})
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Unable to fetch:
http://external.com/network-error.svg
---
Reason: ECONNREFUSED
---
Fetch details:
{
\\"attempt\\": 3,
\\"method\\": \\"GET\\",
\\"requestHeaders\\": {
\\"user-agent\\": \\"got (https://github.com/sindresorhus/got)\\",
\\"accept-encoding\\": \\"gzip, deflate, br\\"
}
}
---"
`)

expect(gotStream).toBeCalledTimes(3)
})
})
})
Loading