[Bug] ARM64 Build Failure Due to JavaScript Heap Out of Memory on M1 (16 GB RAM) #6539
Replies: 3 comments
-
Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
Hey, @kewuguai! I'm here to help you with your technical issues and questions. Let's work together to solve this bug and get you back on track! To resolve the "JavaScript heap out of memory" error when building a custom Docker image for RUN NODE_OPTIONS="--max-old-space-size=8192" pnpm build This command increases the Node.js memory limit to 8GB, which should help prevent the out-of-memory error during the build process [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
try NODE_OPTIONS="--max-old-space-size=6144" pnpm build ? |
Beta Was this translation helpful? Give feedback.
-
Description
I’m attempting to build a custom Docker image for
lobe-chat
on my MacBook Pro M1 (ARM64, 16 GB RAM) to test code modifications, but the build fails duringpnpm build
with a "JavaScript heap out of memory" error (exit code 134). This prevents me from running and testing my changes, especially for addressing the knowledge base search limit. I need a fix or guidance for building on ARM64, as the issue involves@next/[email protected]
. I’ve already increased Docker Desktop memory to 12 GB, but the problem persists.Steps to Reproduce
lobe-chat
repository.docker build --platform linux/arm64 -t lobehub/lobe-chat-database .
.pnpm build
with a memory error.Expected Behavior
Actual Behavior
Environment
node:20
image)Dockerfile
FROM node:20
WORKDIR /app
RUN npm install -g [email protected]
COPY lobe-chat/ .
RUN pnpm install
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build
EXPOSE 3210
CMD ["node", "dist/index.js"]
Build Log
[+] Building 281.5s (11/11) FINISHED docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 362B 0.0s => [internal] load metadata for docker.io/library/node:20-bookworm-slim 1.5s => [auth] library/node:pull token for registry-1.docker.io 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 420B 0.0s => CACHED [1/6] FROM docker.io/library/node:20-bookworm-slim@sha256:ffc11dbf16dd0abcbb7b837410601b4d5592db2d03741e13a4a5336ab74d7ccb 0.0s => => resolve docker.io/library/node:20-bookworm-slim@sha256:ffc11dbf16dd0abcbb7b837410601b4d5592db2d03741e13a4a5336ab74d7ccb 0.0s => [internal] load build context 0.3s => => transferring context: 308.81kB 0.2s => [2/6] WORKDIR /app 0.0s => [3/6] RUN npm install -g [email protected] 2.9s => [4/6] COPY lobe-chat/ . 0.7s => [5/6] RUN pnpm install 99.5s => ERROR [6/6] RUN pnpm build || (echo "Build failed, check logs" && exit 1) 176.8s
[6/6] RUN pnpm build || (echo "Build failed, check logs" && exit 1):
2.084
2.084 > @lobehub/[email protected] build /app
2.084 > next build
2.084
2.921 Attention: Next.js now collects completely anonymous telemetry regarding usage.
2.921 This information is used to shape Next.js' roadmap and prioritize features.
2.921 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
2.921 https://nextjs.org/telemetry
2.921
3.006 ▲ Next.js 15.1.7
3.006 - Experiments (use with caution):
3.006 · webpackMemoryOptimizations
3.006
3.039 Creating an optimized production build ...
3.456 ○ (serwist) The service worker will not be automatically registered, please call 'window.serwist.register()' in 'componentDidMount' or 'useEffect'.
3.460 ✓ (serwist) Bundling the service worker script with the URL '/sw.js' and the scope '/'...
176.0
176.0 <--- Last few GCs --->
176.0
176.0 [19:0x36508250] 172206 ms: Scavenge (reduce) 1991.4 (2080.6) -> 1991.4 (2080.6) MB, 11.45 / 0.00 ms (average mu = 0.379, current mu = 0.062) allocation failure;
176.0 [19:0x36508250] 173940 ms: Mark-Compact (reduce) 1993.0 (2082.2) -> 1993.0 (2082.5) MB, 1724.73 / 0.00 ms (average mu = 0.233, current mu = 0.017) allocation failure; scavenge might not succeed
176.0
176.0
176.0 <--- JS stacktrace --->
176.0
176.0 FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
176.0 ----- Native stack trace -----
176.0
176.1 1: 0xb87744 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
176.1 2: 0xec89cc v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
176.1 3: 0xec8b9c v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
176.1 4: 0x10d082c [node]
176.1 5: 0x10e6d04 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
176.1 6: 0x10bfa6c v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
176.1 7: 0x10c0830 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
176.1 8: 0x109f850 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
176.1 9: 0x10910c8 v8::internal::FactoryBasev8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
176.1 10: 0x1094390 v8::internal::FactoryBasev8::internal::Factory::NewRawTwoByteString(int, v8::internal::AllocationType) [node]
176.1 11: 0x10aa588 v8::internal::Factory::NewStringFromUtf8(v8::base::Vector const&, v8::internal::AllocationType) [node]
176.1 12: 0xedcf60 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [node]
176.1 13: 0xc4bd34 napi_create_string_utf8 [node]
176.1 14: 0xfffc71ba3dc8 [/app/node_modules/.pnpm/@[email protected]/node_modules/@next/swc-linux-arm64-gnu/next-swc.linux-arm64-gnu.node]
176.1 15: 0xfffc710c0668 [/app/node_modules/.pnpm/@[email protected]/node_modules/@next/swc-linux-arm64-gnu/next-swc.linux-arm64-gnu.node]
176.1 16: 0xfffc710be900 [/app/node_modules/.pnpm/@[email protected]/node_modules/@next/swc-linux-arm64-gnu/next-swc.linux-arm64-gnu.node]
176.1 17: 0xfffc6cdb5b04 [/app/node_modules/.pnpm/@[email protected]/node_modules/@next/swc-linux-arm64-gnu/next-swc.linux-arm64-gnu.node]
176.1 18: 0xc6d7b4 node::ThreadPoolWork::ScheduleWork()::{lambda(uv_work_s*, int)#2}::_FUN(uv_work_s*, int) [node]
176.1 19: 0x1802e0c [node]
176.1 20: 0x1806c90 [node]
176.1 21: 0x181a5d4 [node]
176.1 22: 0x1807a4c uv_run [node]
176.1 23: 0xbc55f0 node::SpinEventLoopInternal(node::Environment*) [node]
176.1 24: 0xcf0ecc [node]
176.1 25: 0xcf1818 node::NodeMainInstance::Run() [node]
176.1 26: 0xc65210 node::Start(int, char**) [node]
176.1 27: 0xffffa1137740 [/lib/aarch64-linux-gnu/libc.so.6]
176.1 28: 0xffffa1137818 __libc_start_main [/lib/aarch64-linux-gnu/libc.so.6]
176.1 29: 0xbc3910 [node]
176.2 Aborted
176.3 ELIFECYCLE Command failed with exit code 134.
176.3 Build failed, check logs
Dockerfile:15
13 |
14 | # 调试构建 15 | >>> RUN pnpm build || (echo "Build failed, check logs" && exit 1) 16 |
17 | EXPOSE 3210
ERROR: failed to solve: process "/bin/sh -c pnpm build || (echo "Build failed, check logs" && exit 1)" did not complete successfully: exit code: 1
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/htiy9rbt1k1msaj8brib7w47t
Beta Was this translation helpful? Give feedback.
All reactions