PlayForm / Compress

🗜️ Compress —

Home Page:https://NPMJS.Org/@playform/compress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throws error in vercel and cloudflare

JojokCreator opened this issue · comments

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.

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

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

Legend 🙏

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

@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 ?

I'm on Node 21.7.1.

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

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,
    }),

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

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.

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

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?

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.

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

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

@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 ?

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

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

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()
    ]

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