Client network socket disconnected before secure TLS connection was established

We have our company website running on prismic for our headless CMS, about 4-5 weeks ago this strange error started appearing during our builds, it was initially fixed when we updated our package-lock.json file, however it's back and a lot more aggressive.

Our Stack: Vue/Nuxt + netlify

Does anyone have an idea what causes this error and the steps to completely rid of it?

Here's what the error looks like from netilfy console

12:30:55 PM: [error] request to https://company-website.cdn.prismic.io/api/v2 failed, reason: Client network socket disconnected before secure TLS connection was established
12:30:55 PM:   at ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1461:11)
12:30:55 PM:   at ClientRequest.emit (events.js:315:20)
12:30:55 PM:   at ClientRequest.EventEmitter.emit (domain.js:482:12)
12:30:55 PM:   at TLSSocket.socketErrorListener (_http_client.js:426:9)
12:30:55 PM:   at TLSSocket.emit (events.js:315:20)
12:30:55 PM:   at TLSSocket.EventEmitter.emit (domain.js:482:12)
12:30:55 PM:   at emitErrorNT (internal/streams/destroy.js:92:8)
12:30:55 PM:   at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
12:30:55 PM:   at processTicksAndRejections (internal/process/task_queues.js:84:21)
12:30:55 PM: [error]  /blog/
12:30:55 PM: 
12:30:55 PM: FetchError: request to https://company-website.cdn.prismic.io/api/v2 failed, reason: Client network socket disconnected before secure TLS connection was established
12:30:55 PM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/node-fetch/lib/index.js:1461:11)
12:30:55 PM:     at ClientRequest.emit (events.js:315:20)
12:30:55 PM:     at ClientRequest.EventEmitter.emit (domain.js:482:12)
12:30:55 PM:     at TLSSocket.socketErrorListener (_http_client.js:426:9)
12:30:55 PM:     at TLSSocket.emit (events.js:315:20)
12:30:55 PM:     at TLSSocket.EventEmitter.emit (domain.js:482:12)
12:30:55 PM:     at emitErrorNT (internal/streams/destroy.js:92:8)
12:30:55 PM:     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
12:30:55 PM:     at processTicksAndRejections (internal/process/task_queues.js:84:21)

Hello @amustapha,

These errors usually happen when you send API requests from a proxy set up in your project. A few threads online recommend turning off the SSL certificate verification in the browser, have you tried it?

Thanks,
priyanka

Thanks Priyanka...

We don't have a proxy setup, also none of these solutions worked for me.

As a side note, sometimes we get a build that just works, another time, a build works after retrying once, and sometimes you can retry a dozen times with no luck.

Hello @amustapha

I am not sure why this is happening. When I get these types of errors, I follow these things:

  1. Remove node modules and install them again.
  2. Install all the latest dependencies again with the command.
  3. Deploy again.

Give this a try, and let me know. If it still doesn't work, I need your project source code to run locally.

Thanks,
Priyanka