ECONNRESET error in Next.js fetching

I have this Header.js, but sometimes there is an error on fetching the data.

import styles from './Header.module.scss'
import { createClient } from '@/prismicio'
import HeaderWrapper from '../HeaderWrapper/HeaderWrapper';


const Header = async () => {
    const client = createClient();
    const information = await client.getSingle("information");
    const menu = await client.getSingle("main_menu");


    return (
        <div className={styles.header}>
            {/* <pre>{JSON.stringify(information.data, undefined, 2)}</pre> */}

            <HeaderWrapper information={information} menu={menu} />

        </div>
    )
}

export default Header

Here you have the error that I recevied:

I'm not sure why, but sometimes works, sometimes doesn't.

Let me know if you need more information about it.
Thanks for your help.

and this is the error I have on my terminal when I want to try to run the websiteÑ

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11576:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: read ECONNRESET
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
      at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -4077,
    code: 'ECONNRESET',
    syscall: 'read'
  }
}

Hey Jordi,

What version of Next.js are you using? We've seen some fetching issues in recent Next.js versions (around v13 specifically). Could you try updating to the latest version of Next.js and see if the error persists?

Sam

Hi @samlittlefair , thanks for your answer.

I'm using Netxtjs 14.

this is my package.json:

{
  "name": "XXX",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "slicemachine": "start-slicemachine"
  },
  "dependencies": {
    "@prismicio/client": "^7.3.1",
    "@prismicio/next": "^1.5.0",
    "@prismicio/react": "^2.7.3",
    "eslint": "8.47.0",
    "eslint-config-next": "13.4.19",
    "framer-motion": "^10.16.1",
    "gsap": "^3.12.4",
    "next": "^14.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-router-dom": "^6.15.0",
    "sass": "^1.66.1"
  },
  "devDependencies": {
    "@slicemachine/adapter-next": "^0.3.34",
    "slice-machine-ui": "^1.23.1"
  }
}

Hey Jordi,

Given that you're seeing an ECONNRESET error, I suspect that the error is in your app or on your network. Are you getting the error locally or when you build the project in production?

If it's local, is it possible you have network configurations — such as a VPN or firewall — that could be causing problems?

Sam