Next.js Discord

Discord Forum

Facing this issue in production caused by an internal dependency Next uses

Unanswered
Ali posted this in #help-forum
Open in Discord
AliOP
Error
2|Frontend | TypeError: fetch failed
2|Frontend | at Object.fetch (node:internal/deps/undici/undici:11372:11)
2|Frontend | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
2|Frontend | cause: _ConnectTimeoutError: Connect Timeout Error
2|Frontend | at onConnectTimeout (node:internal/deps/undici/undici:6616:28)
2|Frontend | at node:internal/deps/undici/undici:6574:50
2|Frontend | at Immediate._onImmediate (node:internal/deps/undici/undici:6605:13)
2|Frontend | at process.processImmediate (node:internal/timers:478:21)
2|Frontend | at process.callbackTrampoline (node:internal/async_hooks:130:17) {
2|Frontend | code: 'UND_ERR_CONNECT_TIMEOUT'
2|Frontend | },
2|Frontend | digest: '3747308182'
2|Frontend | }

We are running Next.js version 14.2.3 with Node 20.8.1

We have tried various solutions posted on github issues, and on discord but seem to find no luck to solve this error. If anyone knows any specific versions of Next where it isn't happening, pls let us know!

This is an ongoing issue and is impacting a lot of our live users in production as they are unable to use the App

Plus this was working fine before the POST

30 Replies

AliOP
Yes, we have verified from our BE and everything seems to be working fine locally too
is it intermittent or is it breaking for all users?
AliOP
for all users
we found that it is due to undici dependency used by Next
Persian
I am experiencing this same issue. I was able to identify the issue for the first time yesterday. After every new deploy, many of my functions (which previously worked fine within 1 or 2 seconds) are timing out...
@Ali how did you fix this?
@Persian <@363325086134042627> how did you fix this?
AliOP
Haven't fixed it yet. Still waiting for some fix from the next team for this
Selkirk Rex
i have this issue in development
didnot checked on deployement
what node version u using
in deployment
FROM node:22 AS base
FROM base AS deps
RUN npm install -g pnpm
WORKDIR /app

COPY package.json pnpm-lock.yaml ./
COPY prisma ./prisma
COPY schema.zmodel ./
RUN pnpm install --frozen-lockfile --prefer-frozen-lockfile

FROM base AS builder
RUN npm install -g pnpm

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build

FROM base AS runner

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public

RUN groupadd -r appuser && useradd -r -g appuser appuser

RUN chown -R appuser:appuser .next

USER appuser

CMD ["node", "server.js"]
this is my docker file
AliOP
We r using v20 for node
AliOP
@Multiflora rose seed chalcid if this could be fast tracked, would much appreciate it
@Ali for all users
how did it start happening? via a version upgrade, via a deployment, or just out of the blue? pretty rare that it would happen out of the blue, but from the error my only guess is that your next app has troubles connecting to your backend.
if it doesn't help, i'm honestly out of ideas. things are not known to just break down out of the blue
even if there was some critical bugs affecting the app, it typically only materialises after a commit or a new deployment
I bumped the app to next canary 14.3.0 and it started working but just seems temporary tbh
But if you take a look at Google several people fixed this by either going back to specific versions or in some other hacky ways

https://medium.com/@kaloyan_17221/fix-vercel-next-js-fetch-failed-from-undici-polyfill-8c66346c9c2f

https://medium.com/@pawanjotkaurbaweja/solved-typeerror-fetch-failed-4f7d304c0c68
yeah this bug i have never heard of or seen it, so no clues what it even means, sorry
AliOP
Thanks man for your input! Hopefully it would be fixed in the upcoming next release
Persian
@Ali have you had issues since moving to 14.3.0?
Something had to have caused the issue, whether thans a operating sytem update, nodejs update, next update, SOMETHING is the culprit. Theres no way multiple people are running into the same issue 'all of a sudden' without some specific cause. It would be beneficial to retrace your steps and backout any changes made till you find what the issue is.