Skip to content

Regenerate image derivatives that img.mjs had been skipping - #3316

Closed
enf0rc3 wants to merge 1 commit into
mainfrom
willlaugesen/regenerate-missing-image-derivatives
Closed

Regenerate image derivatives that img.mjs had been skipping#3316
enf0rc3 wants to merge 1 commit into
mainfrom
willlaugesen/regenerate-missing-image-derivatives

Conversation

@enf0rc3

@enf0rc3 enf0rc3 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Split out of #3313, where these files were surfaced. They fix a pre-existing gap in the asset pipeline and stand on their own.

The trap

img.mjs only processes a source image when it has no metadata sidecar:

// Only processes images where there is no json metadata file
if (!fs.existsSync(metaPath)) {
  filesToProcess.push(info);
}

Once a sidecar exists without its derivatives, nothing regenerates them. Three images were stuck that way.

What was stuck

releases/timeline/environment-timeline.png and -button.png were renamed from timeline.png. The sidecar travelled with the source, so img.mjs skipped both, the derivatives kept the old name, and the sidecar kept the old image's dimensions — 1000×535 recorded against an image that is actually 1644×1081. Any consumer trusting those numbers was laying out the wrong box.

api-and-integration/github/github-connections-authorize-app.png had a sidecar and no derivatives at any size. That's the state you get when img.mjs exits mid-write: its toFile() calls at lines 105, 111, 116, 147 and 152 are never awaited, while the sidecar write at line 130 is.

What this does

Deletes the three stale sidecars so img.mjs reprocesses them, and commits the 12 derivative files it produced plus the three corrected sidecars.

The old timeline-*.webp derivatives are unreferenced now, but I left them rather than widening this into a cleanup.

Not fixed here

  • The unawaited toFile() calls. img.mjs carries a header saying it comes from Astro Accelerator and local edits get overwritten, so the race wants its own decision.
  • .jpeg sources. img.mjs writes .jpg derivatives while getDestination builds the fallback URL from the original extension, so /docs/i/x/…jpeg never exists for the three projects/dashboard images. Replace the magnify-and-new-tab figure with an inline lightbox #3313 handles this by falling back to the original file.

Verifying

Nothing references these paths on main today — getImageInfo runs for :img{} directives only, and none of these images use one. So main stays green either way; this makes the assets correct for anything that starts requesting them.

🤖 Generated with Claude Code

img.mjs only processes a source image when it has no metadata sidecar, so
once a sidecar exists without its derivatives nothing regenerates them.
Three images were stuck that way:

- releases/timeline/environment-timeline.png and -button.png were renamed
  from timeline.png, and the sidecar came along with the source, so the
  derivatives kept the old name and the sidecar kept the old image's
  dimensions - 1000x535 recorded against an image that is 1644x1081
- api-and-integration/github/github-connections-authorize-app.png had a
  sidecar and no derivatives at any size, which is the state you get when
  the unawaited toFile calls in img.mjs lose the race with process exit

Deleting the three sidecars let img.mjs write the missing files. Nothing
references the old timeline-*.webp derivatives; they are left in place
rather than widening this to a cleanup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@borland borland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR is redundant when my cleanup PR merges. There's no value in regenerating the image derivatives in the meantime because nothing references them

@team-marketing-branch-protections

Copy link
Copy Markdown

Pull request environment is available at https://stoctodocspr3316.z22.web.core.windows.net.

You can view the ephemeral environment status in Octopus Deploy.

This environment will be automatically deprovisioned when the pull request is closed, or after 7 days of inactivity.

@enf0rc3

enf0rc3 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Not required as #3281 fixes the need and we will use the new approach

@enf0rc3 enf0rc3 closed this Aug 7, 2026
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.

3 participants