next.js
ce881de0 - chore(next/image): improve imgopt api bypass detection for unsupported images (#73909)

Commit
1 year ago
chore(next/image): improve imgopt api bypass detection for unsupported images (#73909) We currently bypass svg and animated images because vector doesn't need to be rasterized and animated will turn to still. However, there are other image types that we implicitly bypass once sharp throws an error message and we catch it here: https://github.com/vercel/next.js/blob/7d1ee4ff209d369d8cfce9ec2d00252cc1b8876f/packages/next/src/server/image-optimizer.ts#L798-L815 We already have existing tests for this behavior here: https://github.com/vercel/next.js/blob/9435b7b9602136aeac77f5ff55bb553dcaa2b01a/test/integration/image-optimizer/test/util.ts#L201 This PR bypasses early so we can avoid sending the buffer, waiting for it to throw the error, and then catching the error. Also note this uncovered some discrepancies in how we handle the max age cache-control so this unifies the behavior.
Author
Parents
Loading