fix(gatsby-plugin-sharp): hot fix for "Generating image thumbnails" progress bar reporting duplicates that don't do actual processing #20839
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This is very hacky - primarly the jobs v2 handling:
plugins right now don't know if they create duplicate jobs - this is internal gatsby core feature that is not exposed to plugins, so plugins potentially would need to implement duplicate jobs tracking themselves (duplicate functionality already built into gatsby). This is not ideal because implementation might not end up 1:1 (or implementations can drift over time)
Instead I listen to internal actions here, which are guaranteed not be emitted for duplicates (for jobs v2 code path). Legacy jobs / jobsv1 don't have any of this and this requires plugins to track things, so we already do that in sharp plugin - I just moved progress bar handling to "better" location so it doesn't display duplicates.
Long/medium term we should have Jobs v2 able to manage progress bar, but currently we are lacking some APIs for this:
fixes #20816
---edited:
we will need new API to provide some metadata for jobs created from same plugin - see #20839 (comment) as general direction
Because of that we don't need to preemptively make any checks, because adding support for progress bar management by jobs API in core won't immediately result in progress bar showing by plugin creating v2 jobs. The check will be added once API is designed and implemented in core, so there shouldn't be any weird regressions like 2 progress bars for same thing or none progress bars