Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server crashes if the image is missing or not found. #179

Open
AllenRobinHubert opened this issue Mar 16, 2024 · 0 comments
Open

Server crashes if the image is missing or not found. #179

AllenRobinHubert opened this issue Mar 16, 2024 · 0 comments

Comments

@AllenRobinHubert
Copy link

AllenRobinHubert commented Mar 16, 2024

How can i efficiently handle cases where an image is not found or does not exist. Right now if an image is not found it basically crashes the server and throws an error.
The below code works fine if an image has been received by the component, else it throws an error.

<Picture
    src={`${imagesDomain}/static/images/tablet/bldog/${blog.card_img}.webp`}
    alt={blog.title}
    objectFit="cover"
    layout="fill"
    quality={50}
    loading="lazy"
  />
E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/utils/throwErrorIfUnsupported.js:9
    throw new Error(`Failed to load ${src}; Invalid image format`); 
          ^

Error: Failed to load http://209.182.232.71:4025/static/images/tablet/bldog/6-reasons-why-a-career-in.webp; Invalid image format        
    at Module.throwErrorIfUnsupported [as default] (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/utils/throwErrorIfUnsupported.js:9:11)
    at Module.getResolvedSrc [as default] (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/utils/getResolvedSrc.js:39:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getProcessedImage [as default] (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/utils/getProcessedImage.js:28:22)
    at async __vite_ssr_exports__.default (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/utils/getImage.js:41:5) 
    at async Module.renderPicture [as default] (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/api/renderPicture.js:54:28)
    at async eval (E:/wamp64/www/ssr-test-project/node_modules/astro-imagetools/components/Picture.astro:12:36)
    at async AstroComponentInstance.render (E:/wamp64/www/ssr-test-project/node_modules/astro/dist/runtime/server/render/astro/instance.js:44:7)
    at async Object.render (E:/wamp64/www/ssr-test-project/node_modules/astro/dist/runtime/server/render/component.js:342:7)        
    at async Module.renderChild (E:/wamp64/www/ssr-test-project/node_modules/astro/dist/runtime/server/render/any.js:36:5)

Node.js v20.9.0

Some time i get the error as following
node:internal/process/promises:289 triggerUncaughtException(err, true /* fromPromise */);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant