The Netlify Next/image handler always fails (_ipx handler throws TypeError)

elastic-golick-b7da4f

Hello,
I have a very strange issue related to Next/image on Netlify. Whenever I use Next/Image on my local machine, there is no issue whatsoever with using Next/image. I have an AWS S3 bucket with my images that I have added as a url in my next.js config. In development mode as well as in an optimized build, these work fine locally. As soon as the _ipx function is in charge on netlify however, no images show up and I get an error that I can’t really debug because it’s seemingly not my code that is the issue.

I use the essential Nextjs plugin (updated yesterday July 27th 2022 to latest version).

Here is the error from the _ipx logs. It repeats for every instance of Next/image whenever an is supposed to load in the browser.


Jul 28, 05:35:15 PM: Unknown application error occurred
TypeError
Jul 28, 05:35:15 PM: 2022-07-28T15:35:15.102Z	undefined	ERROR	Uncaught Exception 	{"errorType":"TypeError","errorMessage":"Cannot read properties of null (reading 'startsWith')","stack":["TypeError: Cannot read properties of null (reading 'startsWith')","    at /var/task/node_modules/ipx/dist/chunks/middleware.cjs:128:12","    at Array.map (<anonymous>)","    at createHTTPSource (/var/task/node_modules/ipx/dist/chunks/middleware.cjs:127:28)","    at createIPX (/var/task/node_modules/ipx/dist/chunks/middleware.cjs:423:24)","    at createIPXHandler (/var/task/node_modules/@netlify/ipx/dist/index.js:16:37)","    at Object.<anonymous> (/var/task/.netlify/functions-internal/_ipx/_ipx.js:7:46)","    at Module._compile (node:internal/modules/cjs/loader:1105:14)","    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)","    at Module.load (node:internal/modules/cjs/loader:981:32)","    at Function.Module._load (node:internal/modules/cjs/loader:822:12)"]}
Jul 28, 05:35:15 PM: e5fd6c56 Duration: 406.68 ms	Memory Usage: 24 MB

Hi @Emilcrafter

We implemented a fix for this issue today. Do you mind testing this again with the most recent version of our plugin, please?

I am getting this issue on version 4.13.1, which is @latest on npm. Is there another version somewhere?

Hey @Emilcrafter,

Yes, that is the latest version. I tried right now to load your home page with the images but all images seem to load and the function logs seem empty. Do you have a specific image with which this happens?

Hi, I found the error. My next.config.js file had a nullish element in the images.domains array, since I had removed a url and left the comma. This worked using a local next build but did not work with _ipx. Perhaps this is an issue that should be resolved?

I won’t call this an issue per se, but maybe an edge case to support a non-common or a rare use-case. We’ll add this to our discussion with the devs to see if this is something we would be adding support for.