Skip to content

Commit 0926c73

Browse files
sidharthachatterjeeGatsbyJS Bot
authored and
GatsbyJS Bot
committed
fix(gatsby-plugin-sharp): Set a unique uuid for each job (#17693)
1 parent 4e67a30 commit 0926c73

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

packages/gatsby-plugin-sharp/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"progress": "^2.0.3",
2525
"semver": "^5.7.1",
2626
"sharp": "^0.23.0",
27-
"svgo": "^1.3.0"
27+
"svgo": "^1.3.0",
28+
"uuid": "^3.3.3"
2829
},
2930
"devDependencies": {
3031
"@babel/cli": "^7.6.0",

packages/gatsby-plugin-sharp/src/scheduler.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const _ = require(`lodash`)
22
const { existsSync } = require(`fs`)
3+
const uuidv4 = require(`uuid/v4`)
34
const queue = require(`async/queue`)
45
const { processFile } = require(`./process-file`)
56
const { createProgress } = require(`./utils`)
@@ -66,16 +67,19 @@ exports.scheduleJob = async (
6667

6768
if (!isQueued) {
6869
// Create image job
70+
const jobId = uuidv4()
6971
boundActionCreators.createJob(
7072
{
71-
id: `processing image ${job.inputPath}`,
73+
id: jobId,
74+
description: `processing image ${job.inputPath}`,
7275
imagesCount: 1,
7376
},
7477
{ name: `gatsby-plugin-sharp` }
7578
)
7679

7780
q.push(cb => {
7881
runJobs(
82+
jobId,
7983
inputFileKey,
8084
boundActionCreators,
8185
pluginOptions,
@@ -89,6 +93,7 @@ exports.scheduleJob = async (
8993
}
9094

9195
function runJobs(
96+
jobId,
9297
inputFileKey,
9398
boundActionCreators,
9499
pluginOptions,
@@ -105,7 +110,7 @@ function runJobs(
105110
// Update job info
106111
boundActionCreators.setJob(
107112
{
108-
id: `processing image ${job.inputPath}`,
113+
id: jobId,
109114
imagesCount: jobs.length,
110115
},
111116
{ name: `gatsby-plugin-sharp` }
@@ -143,7 +148,7 @@ function runJobs(
143148

144149
boundActionCreators.setJob(
145150
{
146-
id: `processing image ${job.inputPath}`,
151+
id: jobId,
147152
imagesFinished,
148153
},
149154
{ name: `gatsby-plugin-sharp` }
@@ -152,10 +157,7 @@ function runJobs(
152157
)
153158

154159
Promise.all(promises).then(() => {
155-
boundActionCreators.endJob(
156-
{ id: `processing image ${job.inputPath}` },
157-
{ name: `gatsby-plugin-sharp` }
158-
)
160+
boundActionCreators.endJob({ id: jobId }, { name: `gatsby-plugin-sharp` })
159161
cb()
160162
})
161163
} catch (err) {

yarn.lock

+28-2
Original file line numberDiff line numberDiff line change
@@ -11065,7 +11065,7 @@ is-text-path@^2.0.0:
1106511065
dependencies:
1106611066
text-extensions "^2.0.0"
1106711067

11068-
is-typedarray@~1.0.0:
11068+
is-typedarray@^1.0.0, is-typedarray@~1.0.0:
1106911069
version "1.0.0"
1107011070
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
1107111071

@@ -19111,6 +19111,13 @@ type-of@^2.0.1:
1911119111
version "2.0.1"
1911219112
resolved "https://registry.yarnpkg.com/type-of/-/type-of-2.0.1.tgz#e72a1741896568e9f628378d816d6912f7f23972"
1911319113

19114+
typedarray-to-buffer@^3.1.5:
19115+
version "3.1.5"
19116+
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
19117+
integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==
19118+
dependencies:
19119+
is-typedarray "^1.0.0"
19120+
1911419121
typedarray@^0.0.6, typedarray@~0.0.5:
1911519122
version "0.0.6"
1911619123
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
@@ -20439,7 +20446,7 @@ wrappy@1:
2043920446
version "1.0.2"
2044020447
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
2044120448

20442-
[email protected], write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, write-file-atomic@^2.4.2, write-file-atomic@^3.0.0:
20449+
[email protected], write-file-atomic@^2.0.0, write-file-atomic@^2.3.0:
2044320450
version "2.4.1"
2044420451
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.1.tgz#d0b05463c188ae804396fd5ab2a370062af87529"
2044520452
integrity sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg==
@@ -20448,6 +20455,25 @@ [email protected], write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, wri
2044820455
imurmurhash "^0.1.4"
2044920456
signal-exit "^3.0.2"
2045020457

20458+
write-file-atomic@^2.4.2:
20459+
version "2.4.3"
20460+
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481"
20461+
integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==
20462+
dependencies:
20463+
graceful-fs "^4.1.11"
20464+
imurmurhash "^0.1.4"
20465+
signal-exit "^3.0.2"
20466+
20467+
write-file-atomic@^3.0.0:
20468+
version "3.0.0"
20469+
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.0.tgz#1b64dbbf77cb58fd09056963d63e62667ab4fb21"
20470+
integrity sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q==
20471+
dependencies:
20472+
imurmurhash "^0.1.4"
20473+
is-typedarray "^1.0.0"
20474+
signal-exit "^3.0.2"
20475+
typedarray-to-buffer "^3.1.5"
20476+
2045120477
2045220478
version "0.0.2"
2045320479
resolved "https://registry.yarnpkg.com/write-file-stdout/-/write-file-stdout-0.0.2.tgz#c252d7c7c5b1b402897630e3453c7bfe690d9ca1"

0 commit comments

Comments
 (0)