Compress icon indicating copy to clipboard operation
Compress copied to clipboard

Throws error in vercel and cloudflare

Open JojokCreator opened this issue 1 year ago • 20 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.

JojokCreator avatar Feb 15 '24 06:02 JojokCreator

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

jugoetz avatar Feb 19 '24 11:02 jugoetz

Running into this issue on Vercel as well, even after pinning to [email protected] according to this: https://github.com/lovell/sharp/issues/3870

hamatoyogi avatar Mar 08 '24 11:03 hamatoyogi

@hamatoyogi @jugoetz @JojokCreator https://github.com/Playform/AstroCompress/issues/316#issuecomment-2015148990

Fixed in v2.2.17

NikolaRHristov avatar Mar 22 '24 16:03 NikolaRHristov

Legend 🙏

JojokCreator avatar Mar 23 '24 04:03 JojokCreator

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 avatar Mar 26 '24 23:03 kristianfrost

@kristianfrost

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

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 ?

NikolaRHristov avatar Mar 26 '24 23:03 NikolaRHristov

I'm on Node 21.7.1.

kristianfrost avatar Mar 26 '24 23:03 kristianfrost

Like in https://github.com/Playform/AstroCompress/issues/319 can you share an image so we can debug this further ? @kristianfrost

NikolaRHristov avatar Mar 27 '24 00:03 NikolaRHristov

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 avatar Mar 30 '24 05:03 JojokCreator

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

JojokCreator avatar Mar 30 '24 05:03 JojokCreator

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 avatar Mar 30 '24 11:03 NikolaRHristov

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

NikolaRHristov avatar Apr 01 '24 12:04 NikolaRHristov

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?

jugoetz avatar Apr 01 '24 14:04 jugoetz

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 https://github.com/Playform/CompressAstro/issues/324, but they're the same in terms of functionality.

NikolaRHristov avatar Apr 01 '24 14:04 NikolaRHristov

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

JojokCreator avatar Apr 02 '24 08:04 JojokCreator

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

JojokCreator avatar Apr 03 '24 03:04 JojokCreator

@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 - https://github.com/withastro/astro/pull/10616.

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

NikolaRHristov avatar Apr 03 '24 17:04 NikolaRHristov

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

NikolaRHristov avatar Apr 05 '24 13:04 NikolaRHristov

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

JojokCreator avatar Apr 07 '24 03:04 JojokCreator

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

jugoetz avatar Apr 09 '24 09:04 jugoetz

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

NikolaRHristov avatar May 09 '24 17:05 NikolaRHristov