fix: revise format-handling logic in noop.ts and service.ts#14861
fix: revise format-handling logic in noop.ts and service.ts#14861eya46 wants to merge 3 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest 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 |
CodSpeed Performance ReportMerging #14861 will not alter performanceComparing Summary
Footnotes |
|
@Princesseuh when you have some time can you look at this? |
| delete newOptions.format; | ||
|
|
||
| return newOptions; | ||
| if (baseService.validateOptions) { |
There was a problem hiding this comment.
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.
|
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. |
|
@s5bug In the meantime you can pin Astro to 5.15.8 |
|
@eya46 do you need help to address Erika's feedback? |
|
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. |
After upgrading to the latest Astro (>=5.15.9), all SVG images stopped displaying.
Issues found:
passthroughImageServiceenabled, SVG images returnContent-Type: image/nulland fail to render (JPG works).After downgrading Astro, the regression starts at 5.15.9.
Related issues:
passthroughImageServicegenerate webp #14776: introducedvalidateOptionsin noop.ts to address itdelete newOptions.format;->"Content-Type": mime.lookup(format) ?? `image/${format}-> BrowserContent-Type: image/null-> image boom (svg)Changes
I believe the issue in #14721 originates from the
options.format = DEFAULT_OUTPUT_FORMATassignment in service.ts.To address this, I added a flag to prevent setting a default output format when the noop service is used.
before:

after:

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.