Next.js Discord

Discord Forum

Vercel deployment network error - Request body length does not match content-length header

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
I get this error when deploying to vercel - specifically when generating static pages.

ApolloError: fetch failed
    at new ApolloError (/vercel/path0/.next/server/chunks/279.js:6649:28)
    at /vercel/path0/.next/server/chunks/279.js:6039:77
    at both (/vercel/path0/.next/server/chunks/279.js:10660:32)
    at /vercel/path0/.next/server/chunks/279.js:10651:36
    at new Promise (<anonymous>)
    at Object.then (/vercel/path0/.next/server/chunks/279.js:10650:24)
    at Object.error (/vercel/path0/.next/server/chunks/279.js:10662:49)
    at notifySubscription (/vercel/path0/.next/server/chunks/279.js:1078:26)
    at onNotify (/vercel/path0/.next/server/chunks/279.js:1114:5)
    at SubscriptionObserver.error (/vercel/path0/.next/server/chunks/279.js:1167:17) {
  graphQLErrors: [],
  protocolErrors: [],
  clientErrors: [],
  networkError: TypeError: fetch failed
      at Object.fetch (node:internal/deps/undici/undici:11457:11) {
    cause: RequestContentLengthMismatchError: Request body length does not match content-length header
        at AsyncWriter.end (node:internal/deps/undici/undici:10241:19)
        at writeIterable (node:internal/deps/undici/undici:10149:16) {
      code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
    }
  },
  extraInfo: undefined


Has anyone come across this before?

12 Replies

HimalayanOP
bump
could be the same as this issue. if so, downgrading to 13.4.7 would work.
https://github.com/vercel/next.js/issues/48744
HimalayanOP
Hey thanks, tried this.
Unfortunately no luck.

Some further context, I am using with next app directory.
"@as-integrations/next"

import { startServerAndCreateNextHandler } from "@as-integrations/next";
import { ApolloServer } from "@apollo/server";
oh. the error message is obviously related to Vercel's node-fetch related issue when calling upstream via http/1.1 though.
Does it work locally on your mac/win/wsl?
HimalayanOP
Yeah everything works correctly locally
did you pin the exact version without ^ ?
"next": "13.4.7"
HimalayanOP
Indeed, can confirm
just curious, why do you want to run a GraphQL server on Vercel, which is serverless runtimes?
HimalayanOP
Experimenting with the concepts in this article for a personal website. Interested in the idea of running the Apollo server with next rather than as a seperate deployment.

https://javascript.plainenglish.io/using-apollo-server-with-nextjs-13-app-dir-part-1-google-auth-with-nextauth-prisma-ca242c92599e

Right now my apollo client actually connects to contentful graphQL api and to the Apollo server within my app.

Contentful used for content, obviously, and then I am playing with apollo server and mongoDB to track things like post likes etc.
i use a GraphQL server. it’s really nice for both web and native apps. what i want to know is why you want to host it on Vercel, precisely AWS Lambda.
HimalayanOP
The next app I want to host on vercel. The Apollo server is just integrated in with it
@Himalayan did you find a fix for it?