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

Out of memory when used in conjunction with vite-plugin-pwa #653

Open
ispyinternet opened this issue May 7, 2024 · 6 comments
Open

Out of memory when used in conjunction with vite-plugin-pwa #653

ispyinternet opened this issue May 7, 2024 · 6 comments
Labels
verifying Checking the occurrence conditions

Comments

@ispyinternet
Copy link

I'm using vite-plug-pwa to setup service workers.

When I try to combine this plugin with sveltekit-adapter-aws ('edge-bundled'), I get a v8 JavasScript heap out of memory error. I can remove either plugin, and the project will build ok.

<--- Last few GCs --->

[204930:0x61551c0]   141045 ms: Mark-Compact 1995.0 (2084.7) -> 1978.3 (2085.2) MB, 1673.13 / 0.01 ms  (average mu = 0.235, current mu = 0.167) allocation failure; scavenge might not succeed
[204930:0x61551c0]   144935 ms: Mark-Compact 1996.1 (2085.4) -> 1980.5 (2086.2) MB, 3728.52 / 0.01 ms  (average mu = 0.113, current mu = 0.041) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xca5430 node::Abort() [node]
 2: 0xb7807d  [node]
 3: 0xeca0b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0xeca397 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 5: 0x10dc0e5  [node]
 6: 0x10dc674 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0x10f3564 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 8: 0x10f3d7c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0x10ca081 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0x10cb215 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11: 0x10a8866 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
12: 0x15035f6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x193cef6  [node]

System:

  System:
    OS: Linux 6.1 Amazon Linux 2023
    CPU: (4) x64 AMD EPYC 7571
    Memory: 8.28 GB / 15.45 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
@jill64
Copy link
Owner

jill64 commented May 7, 2024

Thank you for opening this issue!
Does the heap out of memory error occur on the server side?

The edge-bundled architecture handles all requests with Lambda@Edge.
Lambda@Edge has strict execution environment limits, and function memory size is limited to 128MB.
(see below)

https://github.com/jill64/sveltekit-adapter-aws/blob/main/docs/edge-bundled/README.md
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-lambda-at-edge

Screenshot 2024-05-08 at 6 06 03

I've never used vite-plug-pwa, but perhaps the edge-bundled architecture can run out of memory.
This is a limitation of the AWS platform and there is no way around it.
Try choosing other architectures depending on your use case.

@ispyinternet
Copy link
Author

ispyinternet commented May 7, 2024

Hi, this is during build with vite, I know vite-plugin-pwa has to create a manifest for all the files to cache in the service worker - if that is somehow mixing into what your plugin does to create some recursive loop or something that is causing the heap to overflow 🤷

@jill64
Copy link
Owner

jill64 commented May 8, 2024

Understood.
I will look into it.

@jill64 jill64 added the verifying Checking the occurrence conditions label May 8, 2024
@ispyinternet
Copy link
Author

Great, occasionally it does build, it's probably a project-size thing, so maybe try and clone a large sveltekit project to test against.

@ispyinternet
Copy link
Author

might be relevant: https://vite-pwa-org.netlify.app/frameworks/sveltekit#sveltekit-and-adapters

@jill64
Copy link
Owner

jill64 commented May 13, 2024

I tried to create a SvelteKit project with 6500 routes but could not reproduce the problem.

https://github.com/jill64/saa-issue-653

Is it possible for you to provide a repro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
verifying Checking the occurrence conditions
Projects
None yet
Development

No branches or pull requests

2 participants