Skip to content

fix: revise format-handling logic in noop.ts and service.ts#14861

Closed
eya46 wants to merge 3 commits intowithastro:mainfrom
eya46:fix-noop-bug
Closed

fix: revise format-handling logic in noop.ts and service.ts#14861
eya46 wants to merge 3 commits intowithastro:mainfrom
eya46:fix-noop-bug

Conversation

@eya46
Copy link

@eya46 eya46 commented Nov 21, 2025

After upgrading to the latest Astro (>=5.15.9), all SVG images stopped displaying.

Issues found:

  • With passthroughImageService enabled, SVG images return Content-Type: image/null and fail to render (JPG works).

After downgrading Astro, the regression starts at 5.15.9.
Related issues:

delete newOptions.format; -> "Content-Type": mime.lookup(format) ?? `image/${format} -> Browser Content-Type: image/null -> image boom (svg)

Changes

I believe the issue in #14721 originates from the options.format = DEFAULT_OUTPUT_FORMAT assignment in service.ts.
To address this, I added a flag to prevent setting a default output format when the noop service is used.

Although my JPG images still return image/null (but browsers can display them), SVG images now work correctly.

before:
image

image

after:
image

image

Testing

I wasn’t sure how to write it.

Docs

There shouldn't be much to change. This aligns better with the note in #configure-no-op-passthrough-service
stating that Note that Astro does not perform any image transformation and processing in these environments.

@changeset-bot
Copy link

changeset-bot bot commented Nov 21, 2025

🦋 Changeset detected

Latest commit: 8a10f23

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Nov 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 21, 2025

CodSpeed Performance Report

Merging #14861 will not alter performance

Comparing eya46:fix-noop-bug (8a10f23) with main (78ed8b5)1

Summary

✅ 6 untouched

Footnotes

  1. No successful run was found on main (7d67434) during the generation of this report, so 78ed8b5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@florian-lefebvre
Copy link
Member

@Princesseuh when you have some time can you look at this?

delete newOptions.format;

return newOptions;
if (baseService.validateOptions) {
Copy link
Member

Choose a reason for hiding this comment

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

This works, but I think I'd rather that the validation part of baseService be moved into a reusable function, and the services could choose to either re-use all of baseService by using it like here, or use the function if they don't want any of the side effects.

@s5bug
Copy link

s5bug commented Dec 1, 2025

Is there a workaround I can use at the moment? This is getting me in dev trying to work with SVGs: none of them are rendering.

@florian-lefebvre
Copy link
Member

@s5bug In the meantime you can pin Astro to 5.15.8

@florian-lefebvre
Copy link
Member

@eya46 do you need help to address Erika's feedback?

@florian-lefebvre florian-lefebvre added the needs response Issue needs response from OP label Dec 3, 2025
@eya46
Copy link
Author

eya46 commented Dec 4, 2025

I'm still not very familiar with Astro's source code, and work over the past few months has left me with little motivation to write code.
This PR will likely be delayed for a long time, so I'll convert it into an issue for now and hope someone can help resolve it.
上班真的太坏了,现在下班就想躺着

@eya46 eya46 closed this Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs response Issue needs response from OP pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants