Skip to content

Commit

Permalink
Switch createContentDigest to api-runner-node
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Oct 26, 2021
1 parent a69586f commit c25860f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-core-utils/src/create-content-digest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const createContentDigest = (
input: BinaryLike | string | any
): string => {
if (typeof input === `object` && !Buffer.isBuffer(input)) {
return hasher.hash({ ...input, internal: null })
return hasher.hash(input)
}

return hashPrimitive(input)
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-source-drupal/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ ${JSON.stringify(webhookBody, null, 4)}`

drupalFetchIncrementalActivity.start()

console.log(
urlJoin(baseUrl, `gatsby-fastbuilds/sync/`, lastFetched.toString())
)
try {
// Hit fastbuilds endpoint with the lastFetched date.
const res = await requestQueue.push([
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-source-drupal/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ ${JSON.stringify(nodeToUpdate, null, 4)}
internal: null,
})

console.log({ oldDigest, newDigest: node.internal.contentDigest })
if (oldDigest !== node.internal.contentDigest) {
if (node.internal.owner) {
delete node.internal.owner
Expand Down
23 changes: 22 additions & 1 deletion packages/gatsby/src/utils/api-runner-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const { codeFrameColumns } = require(`@babel/code-frame`)
const fs = require(`fs-extra`)
const { getCache } = require(`./get-cache`)
import { createNodeId } from "./create-node-id"
const { createContentDigest } = require(`gatsby-core-utils`)
const {
createContentDigest: _createContentDigest,
} = require(`gatsby-core-utils`)
import {
buildObjectType,
buildUnionType,
Expand All @@ -31,6 +33,25 @@ const { getNonGatsbyCodeFrameFormatted } = require(`./stack-trace-utils`)
const { trackBuildError, decorateEvent } = require(`gatsby-telemetry`)
import errorParser from "./api-runner-error-parser"

// Override createContentDigest to remove autogenerated data from nodes to
// ensure consistent digests.
function createContentDigest(node) {
return _createContentDigest({
...node,
internal: {
...node.internal,
// Remove auto-generated fields that'd prevent
// creating a consistent contentDigest.
contentDigest: undefined,
owner: undefined,
fieldOwners: undefined,
ignoreType: undefined,
counter: undefined,
},
fields: undefined,
})
}

if (!process.env.BLUEBIRD_DEBUG && !process.env.BLUEBIRD_LONG_STACK_TRACES) {
// Unless specified - disable longStackTraces
// as this have severe perf penalty ( http://bluebirdjs.com/docs/api/promise.longstacktraces.html )
Expand Down

0 comments on commit c25860f

Please sign in to comment.