Reason: read ECONNRESET - Fetch Error

Hey There,

We are running a next.js build on the newest version and keep running into a fetch error. We have tried several different techniques to get this to work without any luck.

The build fails about every 5-7 times seemingly random.

Could this be a problem with the API or the domain? Or is this an issue with Netlify/NextJS?

Any guidance would be appreciated! Below you will find the deploy details.

11:49:20 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
11:49:20 AM: ────────────────────────────────────────────────────────────────
11:49:20 AM: ​
11:49:20 AM: Next.js cache restored.
11:49:20 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
11:49:20 AM: ​
11:49:20 AM: (@netlify/plugin-nextjs onPreBuild completed in 429ms)
11:49:20 AM: ​
11:49:20 AM: ────────────────────────────────────────────────────────────────
11:49:20 AM:   2. netlify-plugin-cache-nextjs (onPreBuild event)             
11:49:20 AM: ────────────────────────────────────────────────────────────────
11:49:20 AM: ​
11:49:20 AM: .next/cache exists on disk
11:49:20 AM: Restored the cached .next folder at the location .next/cache
11:49:20 AM: ​
11:49:20 AM: (netlify-plugin-cache-nextjs onPreBuild completed in 297ms)
11:49:20 AM: ​
11:49:20 AM: ────────────────────────────────────────────────────────────────
11:49:20 AM:   3. build.command from netlify.toml                            
11:49:20 AM: ────────────────────────────────────────────────────────────────
11:49:20 AM: ​
11:49:20 AM: $ npm run build
11:49:21 AM: > next-js-boilerplate@1.0.0 build
11:49:21 AM: > next build
11:49:22 AM: info  - Checking validity of types...
11:49:40 AM: warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
11:49:53 AM: ./src/pages/_document.tsx
11:49:53 AM: 23:29  Warning: Dangerous property 'dangerouslySetInnerHTML' found  react/no-danger
11:49:53 AM: info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
11:49:53 AM: info  - Creating an optimized production build...
11:49:53 AM: info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
11:49:55 AM: warn - You have enabled the JIT engine which is currently in preview.
11:49:55 AM: warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
11:49:57 AM: info  - Using external babel configuration from /opt/build/repo/.babelrc
11:50:12 AM: info  - Compiled successfully
11:50:12 AM: info  - Collecting page data...
11:50:16 AM: info  - Generating static pages (0/456)
11:50:23 AM: Error occurred prerendering page "/jobs/view/postal-clerk-holiday-season-from-nov-15-to-jan-15". Read more: https://nextjs.org/docs/messages/prerender-error
11:50:23 AM: FetchError: request to https://api.benecms.com/rest/skillscentre/Jobs/postal-clerk-holiday-season-from-nov-15-to-jan-15 failed, reason: read ECONNRESET
11:50:23 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/node-fetch/lib/index.js:1461:11)
11:50:23 AM:     at ClientRequest.emit (node:events:390:28)
11:50:23 AM:     at TLSSocket.socketErrorListener (node:_http_client:447:9)
11:50:23 AM:     at TLSSocket.emit (node:events:390:28)
11:50:23 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
11:50:23 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
11:50:23 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
11:50:25 AM: info  - Generating static pages (114/456)
11:50:32 AM: info  - Generating static pages (228/456)
11:50:39 AM: info  - Generating static pages (342/456)
11:50:46 AM: info  - Generating static pages (456/456)
11:50:46 AM: > Build error occurred
11:50:46 AM: Error: Export encountered errors on following paths:
11:50:46 AM: 	/jobs/view/[id]: /jobs/view/postal-clerk-holiday-season-from-nov-15-to-jan-15
11:50:46 AM:     at /opt/build/repo/node_modules/next/dist/export/index.js:500:19
11:50:46 AM:     at runMicrotasks (<anonymous>)
11:50:46 AM:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
11:50:46 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:50:46 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:1006:17
11:50:46 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:50:46 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:880:13
11:50:46 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:50:46 AM:     at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:82:25)
11:50:46 AM: ​
11:50:46 AM: ────────────────────────────────────────────────────────────────
11:50:46 AM:   "build.command" failed                                        
11:50:46 AM: ────────────────────────────────────────────────────────────────
11:50:46 AM: ​
11:50:46 AM:   Error message
11:50:46 AM:   Command failed with exit code 1: npm run build
11:50:46 AM: ​
11:50:46 AM:   Error location
11:50:46 AM:   In build.command from netlify.toml:
11:50:46 AM:   npm run build
11:50:46 AM: ​
11:50:46 AM:   Resolved config
11:50:46 AM:   build:
11:50:46 AM:     command: npm run build
11:50:46 AM:     commandOrigin: config
11:50:46 AM:     environment:
11:50:46 AM:       - ALGOLIA_API_KEY
11:50:46 AM:       - ALGOLIA_BASE_URL
11:50:46 AM:       - NEXT_PRIVATE_TARGET
11:50:46 AM:     publish: /opt/build/repo/.next
11:50:46 AM:     publishOrigin: config
11:50:46 AM:   plugins:
11:50:46 AM:     - inputs: {}
11:50:46 AM:       origin: ui
11:50:46 AM:       package: '@algolia/netlify-plugin-crawler'
11:50:46 AM:     - inputs:
11:50:46 AM:         prettyURLs: true
11:50:46 AM:         trailingSlash: true
11:50:46 AM:       origin: config
11:50:46 AM:       package: '@netlify/plugin-sitemap'
11:50:46 AM:     - inputs: {}
11:50:46 AM:       origin: config
11:50:46 AM:       package: '@netlify/plugin-nextjs'
11:50:46 AM:     - inputs: {}
11:50:46 AM:       origin: config
11:50:46 AM:       package: netlify-plugin-cache-nextjs
11:50:47 AM: Caching artifacts
11:50:47 AM: Started saving node modules
11:50:47 AM: Finished saving node modules
11:50:47 AM: Started saving build plugins
11:50:47 AM: Finished saving build plugins
11:50:47 AM: Started saving pip cache
11:50:47 AM: Finished saving pip cache
11:50:47 AM: Started saving emacs cask dependencies
11:50:47 AM: Finished saving emacs cask dependencies
11:50:47 AM: Started saving maven dependencies
11:50:47 AM: Finished saving maven dependencies
11:50:47 AM: Started saving boot dependencies
11:50:47 AM: Finished saving boot dependencies
11:50:47 AM: Started saving rust rustup cache
11:50:47 AM: Finished saving rust rustup cache
11:50:47 AM: Started saving go dependencies
11:50:47 AM: Finished saving go dependencies
11:50:47 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:50:47 AM: Creating deploy upload records
11:50:47 AM: Failing build: Failed to build site
11:50:47 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
11:50:47 AM: Finished processing build request in 1m57.887791566s

Hey there, @dana-blackbean :wave:

Thanks for reaching out! Can you share a link to your site as well as your project repo, please? Additionally, can you confirm if this was working before you upgraded to the latest version of the plugin?

Hey @hillary

Of course here is the repo for the project: https://github.com/Blackbeancreative/skills-centre as well as the live URL https://skillscentre.ca/

Yea, we just had this problem pop up recently. We tried to upgrade to the latest version to hopefully resolve but we are still seeing the same issues.

Thanks for the quick response! When you say upgrade to the latest version, did you do that today? In your package-lock.json it looks like you are using plugin version 4.1.1, however we released 4.1.2 today.

If you haven’t already tried version 4.1.2, that would be my first suggestion. Let us know!

We have made the following update to the version but are still experiencing the same error.

We are seeing ECONNRESET issues in our builds all of the sudden today. Running Nuxt app against DatoCMS.

5:31:39 PM: $ nuxt generate --fail-on-error
5:32:30 PM: [error] [ApolloCLient Network error]: FetchError: request to https://graphql.datocms.com/ failed, reason: read ECONNRESET
4:31:37 PM: $ nuxt generate --fail-on-error
4:37:53 PM: [error] [ApolloCLient Network error]: FetchError: request to https://graphql.datocms.com/ failed, reason: read ECONNRESET

Numerous errors like above, in separate builds across a couple of hours.

Please advise support team. Thanks

Any update here @hillary? We’re still seeing this issues and it’s so far only an issue in Netlify builds. Running same builds locally has no issues. So it’s definitely not CMS API issue.

Hey there, @mvandiest and @dana-blackbean :wave: wave:

I have escalated this case to some of our Engineers. @mvandiest, can you please share a URL to your site as well as your repo please? We will need a bit more context as to what you are working with so that we can better understand what might be causing this. Thanks!

1 Like

Sure @hillary,

Here is out Netlfiy site: Netlify App

Repo itself is private. But if you need something specific please let me know.

FYI, we made zero code changes. It just started to be an issue out of nowhere.

1 Like

Same problem here, was working fine for a while with no code changes.

1 Like

could you all confirm which endpoints your builds are trying to connect to? I don’t think they are all the same ones, but it will be useful to get a list of the endpoints.

  • I think that @dana-blackbean is seeing it for https://api.benecms.com (don’t know this service - but have you checked with them to see if they have any network blocks that could affect us?)
  • @mvandiest is seeing it for https://graphql.datocms.com/ (which we assume is pretty available since we know the folks at dato, but would still be worth pinging them to confirm).
  • @CameronCT has not specified what connection is failing on their build.

If you did report a path, and you’ve seen it on other paths, please let us know!

1 Like

Hey @fool,

Yea, we have triple checked the networks blocks from API. We ran several tests on the API to see if we are able to error the API out. After 10,000 requests @ 5ms per ping we were unable to get an error from the API.

Hey @fool, boy that feels rude to say :),

We’ve seen the issue on Dato, and reached out to them and they are seeing nothing in their logs related to them so they believe, and I tend to agree, that it’s not them.

Have seen sporadic issues on these endpoints:

I have not seen it happen for our other internal API network calls, but that may not be conclusive, as we are generating thousands of calls during build cycle and only see a handful of ECONNRESET errors. So it could just be coincidence that we haven’t seen it on our APIs.

FYI, we are adding retry behavior to our apollo clent ATM as a best practice to try and handle these network blips gracefully. In case that helps point someone else on here in the direction of recovery.

We use ApolloClient and are adding apollo-link-retry to our Link chain.

Hey @mvandiest,

If they’re not seeing anything on their end, it’s weird, because based on this:

it might happen by the destination server, which in this case is the CMS. Maybe they’re shutting off the connections from us?

Hey @hrishikesh,

Yeah, seems to be some low level network issue. Could be firewalls/bot detection due to the number of requests.

As I mentioned above, we’ve added retry with exponential backoffs to deal with it. Really the right way to handle it long term anyway. The issue just came out of nowhere and it seemed maybe it was Netlify or API related in general.

So, I can’t say it’s not an issue anymore in terms of it just popping up, but we are gracefully handling it now.

was having the same issue. “Solved” it by keep hitting the Redeploying button, and succeeded on 5th try. Boy did it hurt to pay for all this build time

1 Like

What are you using as part of your build process? Might help the Netlify engineers further diagnose.