You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
causes the following error when running npm run build CMD ["node", "server.js"], from within the next.js docker
TypeError: t.mask is not a function
at e.exports.mask (/app/.next/server/chunks/235.js:1:59645)
at h.frame (/app/.next/server/chunks/235.js:1:78447)
at h.send (/app/.next/server/chunks/235.js:1:80497)
at L.send (/app/.next/server/chunks/235.js:2:9182)
at o.send (/app/.next/server/chunks/235.js:2:16756)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
docker file
# https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
# RUN yarn build
# If using npm comment out above and use below instead
RUN npm install
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
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
CMD ["node", "server.js"]
Or causes the connection to hang when using CMD ["npm ", "run", "dev"] from within the next.js docker file
docker file
# https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
# RUN yarn build
# If using npm comment out above and use below instead
RUN npm install
RUN npm run build
CMD ["npm ", "run", "dev"]
Other notes
For both docker files there are no errors in the surrealdb docker container
Running next.js not in docker, and connect to the surrealdb docker container with 0.0.0.0:8000, works correctly
Using the rust sdk with a identical setup works correctly, with rust and surrealdb both in a docker container, connected with a docker compose network let db = Surreal::new::<Ws>("surrealdb:8000".as_str()).await?;
Steps to reproduce
run this with the docker compose file from above
import { Surreal } from "surrealdb.js";
db.connect("ws://surrealdb:8000/rpc", {
namespace: "url",
database: "url",
auth: {
username: root,
password: root,
},
}
console.log(db);
let res = await db.query(`
select * from test
`);
Hey @NexVeridian, it is quite possible that the docker image used for building nextjs ships an old version of NodeJS out of the box, which probably lacks certain functionality, and which is likely different from the version of NodeJS installed on your system. I've never really tested it, but my guess would be that anything above NodeJS v16 will work, but while you're at it you might aswell set it to node 18 or 20 😃
I think I have an update to date version FROM node:20-alpine AS base
I just swapped it to FROM node:20-bookworm AS base
both have the same TypeError: t.mask is not a function as above
here is the full docker file, same as the one from the next.js docs
# https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
# RUN yarn build
# If using npm comment out above and use below instead
RUN npm install
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
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
CMD ["node", "server.js"]
Describe the bug
When using next.js 14.1.0 within a docker container and docker surrealdb/surrealdb:latest-dev
using a docker url name
db.connect("ws://surrealdb:8000/rpc");
Docker compose file
causes the following error when running npm run build CMD ["node", "server.js"], from within the next.js docker
docker file
Or causes the connection to hang when using CMD ["npm ", "run", "dev"] from within the next.js docker file
docker file
Other notes
let db = Surreal::new::<Ws>("surrealdb:8000".as_str()).await?;
Steps to reproduce
run this with the docker compose file from above
For a runnable example see
https://github.com/NexVeridian/next-url-shortener
at this route http://localhost:3000/stats
and look at these two code file, which is also the same as the above code
https://github.com/NexVeridian/next-url-shortener/blob/main/src/components/db-utils.tsx
https://github.com/NexVeridian/next-url-shortener/blob/main/src/app/stats/db.tsx
Full logs with console.log(db) before the query
db.query causes the TypeError: t.mask is not a function, db.create is ok
Expected behaviour
The query should run
SurrealDB version
1.2.1, docker surrealdb/surrealdb:latest-dev
SurrealDB.js version
0.11.0
Contact Details
nexveridian@gmail.com
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: