-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
astro/image: Failed to parse URL error with Picture component #5051
Comments
It builds fine in stackblitz though |
Indeed. Stackblitz uses Node v16. I'm using Node v18.10.0 running into this error. Switching to Node v16 on my machine resolves the error. Weirdly, switching back to Node v18 and running the build again doesn't produce the error, not even after deleting the |
I've reproduced the issue in my Astro project on Node v18.X on Linux x64. Downgrading to Node 16.X does indeed fix the problem. Note that Astro Image seem to write asset cache inside the |
I think this is a bug upstream based on the stacktrace: GoogleChromeLabs/squoosh#1260 |
Yes, squoosh doesn't currently support Node 18: GoogleChromeLabs/squoosh#1242 The underlying issue is that it uses Closing as this is an upstream bug we can't work around. |
I get |
Definitely create a new issue as this one has been closed. Wild shot in the dark guess, since I've seen similar issues with vite-based projects (not on Astro tho): You might be binding to the IPv6 address of localhost. |
Thanks for the tip, that does indeed seems to be the culprit. I am not sure what the correct resolution in this case would be but I created a new issue for further discussion: #5699. |
i have Failed to parse URL from /_astro/411d6d7d-6a1e-4096-9a88-fc16a9978f2e.CbYZN9Mo.avif
Stack trace:
at node:internal/deps/undici/undici:13178:13
at async getImage$1 (file:///home/daniel/pro/blog/dist/chunks/PostsList_BGGX2qwc.mjs:891:20)
at async file:///home/daniel/pro/blog/dist/chunks/PostsList_BGGX2qwc.mjs:1431:25
at async file:///home/daniel/pro/blog/dist/chunks/PostsList_BGGX2qwc.mjs:1429:27
Caused by:
Invalid URL
at new URL (node:internal/url:816:29)
at fetch (node:internal/deps/undici/undici:9998:25)
at fetch (node:internal/bootstrap/web/exposed-window-or-worker:72:12)
at getImage$1 (file:///home/daniel/pro/blog/dist/chunks/PostsList_BGGX2qwc.mjs:891:26)
at async file:///home/daniel/pro/blog/dist/chunks/PostsList_BGGX2qwc.mjs:1431:25
ELIFECYCLE Command failed with exit code 1. import myImage from "../../assets/images/411d6d7d-6a1e-4096-9a88-fc16a9978f2e.avif"
---
<div class="relative mt-8 flex items-center gap-x-4">
<!--<Picture src="https://preciselab.fra1.digitaloceanspaces.com/blog/img/411d6d7d-6a1e-4096-9a88-fc16a9978f2e.avif"-->
<Picture src={myImage.src}
widths={[256]}
formats={['avif']}
alt={data.author} inferSize={true}
class="h-10 w-10 rounded-full bg-gray-100 object-cover"
></Picture> Of course new URL('/_astro/411d6d7d-6a1e-4096-9a88-fc16a9978f2e.CbYZN9Mo.avif') throws error
but how can I fix it in astro? In config I have export default defineConfig({
site: 'https://gustawdaniel.com', |
What version of
astro
are you using?1.4.7
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm, npm
What operating system are you using?
Linux
Describe the Bug
Trying to build projects with astro/image since version 0.8 fails with the error below. Up to version 0.7.1 the same projects build fine.
The error occurs with jpegs and pngs identically. Switching package managers also has no effect to the better.
Putting the image in the
src/
directory directly, without any subfolders doesn't solve the issue either.The error only occurs with the
<Picture />
component. The build runs fine with the<Image />
component.How to reproduce
Link to Minimal Reproducible Example
https://github.com/mundry/astro-image-issue-url
Participation
The text was updated successfully, but these errors were encountered: