Exit Code 139 (SIGSEGV) in K3s - Next.js app crashes every ~13min
Unanswered
California pilchard posted this in #help-forum
California pilchardOP
Hi ! My Next.js 16.0.7 app running in K8s keeps crashing with exit code 139 (segmentation fault). It has restarted 24 times in 7.5 hours, crashing approximately every 13 minutes.
Environment :
- Next.js: 16.0.7
- React: 19.2.0
- Node: 22-alpine (Docker)
- Platform: K3s cluster
- Resources: 2Gi request / 3Gi limit memory
Key Details :
- Build uses --turbopack flag
- Standalone output mode
- App runs fine initially, then crashes with exit code 139
- No obvious errors in logs before crash
Environment :
- Next.js: 16.0.7
- React: 19.2.0
- Node: 22-alpine (Docker)
- Platform: K3s cluster
- Resources: 2Gi request / 3Gi limit memory
Key Details :
- Build uses --turbopack flag
- Standalone output mode
- App runs fine initially, then crashes with exit code 139
- No obvious errors in logs before crash
7 Replies
California pilchardOP
There is my
Dockerfile :FROM node:20-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]Is this a known issue with Turbopack in production or Next.js 16 + React 19 on Alpine? Any suggestions to prevent the segfaults?
I'm completely stumped on what's causing this. Could it be a package requiring additional native libraries in the Alpine image? Or some incompatibility with the Node 22-alpine base image? I've tried looking at logs but there's nothing obvious before the crash happens.
Thanks! 🙏
I'm completely stumped on what's causing this. Could it be a package requiring additional native libraries in the Alpine image? Or some incompatibility with the Node 22-alpine base image? I've tried looking at logs but there's nothing obvious before the crash happens.
Thanks! 🙏
California pilchardOP
any idea ?
California pilchardOP
I have these errors in logs :
Error: Failed to find Server Action "someid (idk if its private)". This request might be from an older or newer deployment.
Read more: https://nextjs.org/docs/messages/failed-to-find-server-action
at ignore-listed frames
⨯ TypeError: controller[kState].transformAlgorithm is not a function
at ignore-listed frames {
digest: '2426044155'
}California pilchardOP
And before crash :
⨯ Error: {"message":"TypeError: fetch failed","details":"TypeError: fetch failed\n\nCaused by: AggregateError: (ETIMEDOUT)\nAggregateError: \n at internalConnectMultiple (node:net:1122:18)\n at internalConnectMultiple (node:net:1190:5)\n at Timeout.internalConnectMultipleTimeout (node:net:1716:5)\n at listOnTimeout (node:internal/timers:583:11)\n at process.processTimers (node:internal/timers:519:7)","hint":"","code":""}
at ignore-listed frames {
digest: '2164119059'
}
<--- Last few GCs --->
[1:0x7cafc5e60650] 599443 ms: Scavenge 1429.2 (1566.8) -> 1417.2 (1567.3) MB, 34.07 / 0.04 ms (average mu = 0.303, current mu = 0.296) task;
[1:0x7cafc5e60650] 599545 ms: Scavenge 1431.7 (1567.8) -> 1419.5 (1568.6) MB, 40.13 / 0.04 ms (average mu = 0.303, current mu = 0.296) task;
[1:0x7cafc5e60650] 603859 ms: Mark-Compact 1433.9 (1568.8) -> 1412.5 (1568.6) MB, 4050.04 / 0.18 ms (average mu = 0.298, current mu = 0.294) 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 -----California pilchardOP
Ive try so many thing still not working...
I only have this error in k3s cluster but not in my local lapto with simple docker run