#Better error messages from selfhosted docker nextjs?

5 messages · Page 1 of 1 (latest)

proper panther
#

Hi All,

I'm self hosting nextjs in a docker container (for now). Everything is working mostly smoothly, but when things go wrong it's almost impossible to figure out why.

I get error messages like this:

Error: Failed to find Server Action "null". This request might be from an older or newer deployment. Original error: Invariant: Missing 'next-action' header.
    at rv (/app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:1666)
    at /app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:7002
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at rg (/app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:6317)
    at rz (/app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:24715)
    at /app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:27397
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at Object.wrap (/app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:13:16207)
    at /app/apps/frontend/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:27287
    at AsyncLocalStorage.run (node:async_hooks:346:14)

That's usually because some server action couldn't be called, or was dodgy, or w.e. My gripe isn't with the error, it's with figuring out what caused the error.

Is there anyway to improve the error output experience when selfhosting? Ideally by including source maps or something so that specific files and lines of code are highlighted, rather than obscure positions in budled code.

I'll post the dockerfile in a moment.

unique mountainBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

proper panther
#
FROM node:20-alpine AS base

# -----------------------------------------------------
FROM base AS pruner

RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
COPY . .

RUN npx turbo prune frontend --docker

# -----------------------------------------------------
FROM base AS builder

WORKDIR /app
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/package-lock.json ./package-lock.json

RUN npm install

COPY --from=pruner /app/out/full/ .

COPY --from=pruner /app/.prettierignore /app/.prettierignore
COPY --from=pruner /app/.prettierrc /app/.prettierrc

RUN npx turbo run build --filter=frontend...

# -----------------------------------------------------
FROM base AS runner

WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=builder /app/apps/frontend/next.config.js .
COPY --from=builder /app/apps/frontend/package.json .

# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/apps/frontend/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/frontend/.next/static ./apps/frontend/.next/static
# COPY --from=builder --chown=nextjs:nodejs /app/apps/frontend/public ./apps/frontend/public # add public files if they are implemented later

CMD node apps/frontend/server.js
#

Is 'productionBrowserSourceMaps' the option I want?

proper panther
#

I added productionBrowserSourceMaps and the logs still aren't very helpful 😢 Is there anyway to figure out what's causing this error? It only happens to one of my users.