PlayForm / Compress

🗜️ Compress —
https://playform.github.io/Compress/
Other
510 stars 12 forks source link

Throws error in vercel and cloudflare #280

Closed JojokCreator closed 6 months ago

JojokCreator commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

NikolaRHristov commented 7 months ago

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

Fixed in v2.2.17

JojokCreator commented 7 months ago

Legend 🙏

kristianfrost commented 7 months ago

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 commented 7 months ago

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

kristianfrost commented 7 months ago

I'm on Node 21.7.1.

NikolaRHristov commented 7 months ago

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

JojokCreator commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

jugoetz commented 7 months ago

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 commented 7 months ago

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.

JojokCreator commented 7 months ago

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

JojokCreator commented 7 months ago

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

NikolaRHristov commented 7 months ago

@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 commented 7 months ago

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 commented 7 months ago

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

jugoetz commented 7 months ago

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 commented 6 months ago

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