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

Throws error in vercel and cloudflare #280

Closed
JojokCreator opened this issue Feb 15, 2024 · 21 comments
Closed

Throws error in vercel and cloudflare #280

JojokCreator opened this issue Feb 15, 2024 · 21 comments
Assignees
Labels

Comments

@JojokCreator
Copy link

Sorry, error is back again.
When building a static site on Vercel I'm getting an error thrown

generating optimized images
--
09:09:54.680 | free(): invalid size
09:14:20.856 | Error: Command "npm run build" exited with SIGABRT

I've tried using the code from #276

(await import("astro-compress")).default({
	Path: ["./dist"],
	Image: false,
}),

Which worked for a few deployments but is erroring again now.

I also tried on cloudflare but the same error. Builds okay locally.

@jugoetz
Copy link

jugoetz commented Feb 19, 2024

Same issue on Cloudflare. Local build works. Removing astro-compress solves the problem on Cloudflare.

See also:
https://community.cloudflare.com/t/error-deploying-astro-site-was-working/591841

Whether I get free(): invalid size or munmap_chunk(): invalid pointer depends on the node.js version

@hamatoyogi
Copy link

Running into this issue on Vercel as well, even after pinning to sharp@0.32.6 according to this:
lovell/sharp#3870

@NikolaRHristov
Copy link
Member

@hamatoyogi @jugoetz @JojokCreator #316 (comment)

Fixed in v2.2.17

@JojokCreator
Copy link
Author

Legend 🙏

@kristianfrost
Copy link

kristianfrost commented Mar 26, 2024

I am using 2.2.19 and I am still getting an error trying to deploy my Astro build to Cloudfare.

Astro 4.5.9.

00:06:15.719	generating optimized images 
00:06:15.733	munmap_chunk(): invalid pointer
00:06:15.744	Aborted
00:06:15.754	Failed: Error while executing user command. Exited with error code: 134
00:06:15.762	Failed: build command exited with code: 1
00:06:21.260	Failed: error occurred while running build command

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Mar 26, 2024

@kristianfrost

free() was fixed in v2.2.19 https://github.com/Playform/AstroCompress/releases/tag/v2.2.19, see: #319 (comment)

It was due to the cache being enabled by default in libvips. It's now disabled on: https://github.com/Playform/AstroCompress/blob/e8c520555379452c6581839b854fe864feb3daa2/Source/Function/Integration.ts#L260

munmap_chunk(): invalid pointer

I'm assuming is due to an older Node version. Can you share which version of Node are you using ?

@kristianfrost
Copy link

I'm on Node 21.7.1.

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Mar 27, 2024

Like in #319 can you share an image so we can debug this further ? @kristianfrost

@JojokCreator
Copy link
Author

getting munmap_chunk(): invalid pointer and corrupted size vs. prev_size on vercel using node 18 and 20x

when using

    (await import("astro-compress")).default({
      Image: false,
      SVG: false,
    }),

@JojokCreator
Copy link
Author

also just got

14:34:05.241 | 05:34:05   ▶ /_astro/404.BrQoZ2ei_Z1jbl9F.svg (before: 1kB, after: 1kB) (+33ms) (1/9956)
14:34:05.247 | free(): invalid size
14:39:14.985 | Error: Command "npm run build" exited with SIGABRT

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Mar 30, 2024

So, there's a PR available (https://github.com/withastro/astro/pull/10616/files) in favor of disabling the sharp libvips image cache. Maybe it helps. I hope it gets merged and this gets resolved soon.

@NikolaRHristov
Copy link
Member

Can you try the latest astro-compress v2.2.21 and @playform/compress-astro v0.0.2 ? @hamatoyogi @jugoetz @kristianfrost @JojokCreator

@jugoetz
Copy link

jugoetz commented Apr 1, 2024

Tried astro-compress v2.2.21 on Cloudflare, still getting the same error:

16:16:27.763 generating optimized images
16:16:27.778 free(): invalid size
16:16:27.839 Aborted
16:16:27.850 Failed: Error while executing user command. Exited with error code: 134
16:16:27.859 Failed: build command exited with code: 1
16:16:28.750 Failed: error occurred while running build command`

Is @playform/compress-astro smth different / drop-in replacement?

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Apr 1, 2024

Tried astro-compress v2.2.21 on Cloudflare, still getting the same error:

16:16:27.763
generating optimized images

16:16:27.778
free(): invalid size

16:16:27.839
Aborted

16:16:27.850
Failed: Error while executing user command. Exited with error code: 134

16:16:27.859
Failed: build command exited with code: 1

16:16:28.750
Failed: error occurred while running build command`

Heck..

Is @playform/compress-astro smth different / drop-in replacement?

No, @playform/compress-astro is the successor to astro-compress. astro-compress will slowly be deprecated and the namespace freed #324, but they're the same in terms of functionality.

@JojokCreator
Copy link
Author

v2.2.21 built okay on Vercel. Twice so far...

@JojokCreator
Copy link
Author

Spoke too soon free(): invalid size third time lucky ....

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Apr 3, 2024

@kristianfrost @JojokCreator @jugoetz astro v4.5.15 just got released https://github.com/withastro/astro/blob/refs/heads/main/packages/astro/CHANGELOG.md#4515 with the PR merged - withastro/astro#10616.

Can you give that a try with the latest astro-compress v2.2.21 or @playform/compress-astro v0.0.2 ?

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Apr 5, 2024

astro-compress v2.2.22 and @playform/compress v0.0.3 have been released with better error checking and unlimited sharp set to false in Source/Function/Integration.ts. Can you give that a try ? @JojokCreator @jugoetz @hamatoyogi @kristianfrost

@JojokCreator
Copy link
Author

sorry still getting free(): invalid size on vercel with "astro": "^4.5.16", and "astro-compress": "^2.2.22",

@NikolaRHristov NikolaRHristov reopened this Apr 7, 2024
@jugoetz
Copy link

jugoetz commented Apr 9, 2024

I switched to @playform/compress v0.0.3 and building with node 20.12.1 on Cloudflare worked for me now.

There's a change in the docs that I had not noticed before, that may be responsible for the build succeeding now. Previously, astro-compress would be imported at the top of the file like:

import compress from 'astro-compress';

// other stuff

  integrations: [
    ...
    compress(),
    ]

now it is imported inline like

  integrations: [
    ...
    (await import("@playform/compress")).default()
    ]

@NikolaRHristov
Copy link
Member

Should be fixed the latest astro-compress v2.2.23 and @playform/compress v0.0.4

@NikolaRHristov NikolaRHristov added the bug Something isn't working label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants