Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-sharp): fix progressbar & caching layer #19717

Merged
merged 5 commits into from Nov 24, 2019

Conversation

wardpeet
Copy link
Contributor

@wardpeet wardpeet commented Nov 22, 2019

Description

Fixes order of reporter params to fix progressbar. Also added caching layer for ouputFile back. If an outputPath is already scheduled we return the same promise, this was overlooked by me in the worker fix. It doesn't show in simple examples.

Test version: npm install --save gatsby-plugin-sharp@sharp-cache

Before the scheduleJob api was the same as we have in this PR.

const scheduleJob = async (
job,
boundActionCreators,
pluginOptions,
reporter,
reportStatus = true
) => {

Pre 2.3.0:
image

Before:
image

After:
image

Related Issues

#19591 (comment)

@wardpeet wardpeet requested a review from a team as a code owner November 22, 2019 09:47
@wardpeet wardpeet changed the title update sharp tests to fix progressbar fix(gatsby-plugin-sharp): fix progressbar Nov 22, 2019
@wardpeet wardpeet changed the title fix(gatsby-plugin-sharp): fix progressbar fix(gatsby-plugin-sharp): fix progressbar & caching layer Nov 22, 2019
@wardpeet
Copy link
Contributor Author

I made it do less than before as the pre 2.30 version shows 80 and the new one is doing 74. It's not a bug, we process an input file twice which isn't happening with the new code as my check is much more early.

pieh
pieh previously approved these changes Nov 22, 2019
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good! Thanks for adding test for it. Left few comments but feel free to merge

let finishedPromise = Promise.resolve()

// Check if the output file already exists so we don't redo work.
if (cachedOutputFiles.has(outputFile)) {
finishedPromise = cachedOutputFiles.get(outputFile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return early here to avoid && !cachedOutputFiles.has(outputFile) check in L116

packages/gatsby-plugin-sharp/src/index.js Show resolved Hide resolved
@sidharthachatterjee sidharthachatterjee merged commit 7f9d5bb into gatsbyjs:master Nov 24, 2019
@wardpeet wardpeet deleted the fix/sharp-progress branch November 25, 2019 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants