Skip to content

Commit

Permalink
fix(gatsby): Fix OOM from telemetry storing too much (#22752)
Browse files Browse the repository at this point in the history
  • Loading branch information
freiksenet authored Apr 3, 2020
1 parent 5b35acc commit a7281c2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/gatsby/src/query/graphql-runner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import crypto from "crypto"
import {
parse,
validate,
Expand Down Expand Up @@ -164,9 +165,20 @@ export default class GraphQLRunner {
if (typeof statsQuery !== `string`) {
statsQuery = statsQuery.body
}
this.stats.uniqueOperations.add(`${statsQuery}${JSON.stringify(context)}`)

this.stats.uniqueQueries.add(statsQuery)
this.stats.uniqueOperations.add(
crypto
.createHash(`sha1`)
.update(statsQuery)
.update(JSON.stringify(context))
.digest(`hex`)
)

this.stats.uniqueQueries.add(
crypto
.createHash(`sha1`)
.update(statsQuery)
.digest(`hex`)
)
}

const document = this.parse(query)
Expand Down

0 comments on commit a7281c2

Please sign in to comment.