fix: report http status and content type when an image fails to load - #797
Open
Nixxx19 wants to merge 1 commit into
Open
fix: report http status and content type when an image fails to load#797Nixxx19 wants to merge 1 commit into
Nixxx19 wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Nixxx19
force-pushed
the
fix/image-load-error-detail
branch
from
September 1, 2026 06:57
42d891e to
5566955
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #613
fixes #626
refs #575
when a remote image fails to load, satori reports
Unsupported image type: unknownno matter what actually went wrong. the response status is never checked, so a 404 html page goes straight into the magic byte sniffer, comes back as null, and the user gets told their png is an unsupported format.that is why those three issues have gone in circles for two years. people keep saying the same thing, the image opens fine in my browser, it works in dev and not in prod. of course it does, the url is 404ing in prod and nothing in the message says so.
on 0.33.4, an existing 404 and an html page produce the exact same output:
after this change:
two changes. the fetch path now fails when the response was not ok and says which status came back, and when the bytes really are unrecognised the error names the content type the server sent.
i used
res.ok === falserather than!res.okon purpose. satori lets you bring your own fetch, and the test polyfill in this repo returns a bare object with nookon it, so a truthiness check would have thrown on every existing image test and on anyone with a similar polyfill. this way it only fires when a response positively reports failure.#575 reports a cdn image rendering blank without quoting an error, so i have only linked it rather than closing it. if it is the same thing this change will finally say so in the log, and if it is cors or a redirect it will say that instead.
nothing about the fallback behaviour changes. a broken image is still swallowed and the rest of the render still succeeds, you just get told why.
added two tests, one per branch. both fail on main, i checked before adding them. suite is green locally, 514 tests.