Fetch Error on REST API - ECONNRESET

Hi there,

When building our Next website which has a lot of content, we get a lot of failing calls with the following error :

ERROR Unhandled error during request: FetchError: request to https://repo.cdn.prismic.io/api/v2 failed, reason: read ECONNRESET
at ClientRequest.<anonymous> (/var/task/packages/front/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (events.js:314:20)
at TLSSocket.socketErrorListener (_http_client.js:427:9)
at TLSSocket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

Support hasn't been able to help. Anyone here with the same issue ? I have found a few threads mentioning this but so far no solution. That's a really blocking point for us.

This kinda looks like a rate limiting to me. The errors show up on different calls each time, and sometimes all is fine and then after a while nothing works.

I've tried to search for quotas / rate limits on the Prismic API and haven't been able to find anything about that. Is Prismic enforcing some kind of rate limiting on its REST API? Is there any kind of security that could block us thinking we're spamming?

Any help would be greatly appreciated as we're currently a few days ahead of a launch and content on the website is still growing a lot.

Thanks :slight_smile:

Simon

Hello Simon, thanks for reaching out.

I can help you troubleshoot your project. At first glance, I don't know what the problem might be, but if you want, you can send me your GitHub project via dm and the instructions to run it so I can try and reproduce the error.

Let me know what you and your team decide.
Thanks

Hi Paulina,

Thanks for your answer!

I think it may be a bit troublesome to share you the repo so you try to reproduce because it's not that straightforward to get it to run.

I don't know how familiar you are with NextJS, but basically we're doing a bunch of calls to the prismic api in the getStaticProps() functions of our pages. Nothing crazy but we do have quite a lot of content (around 1k pages). As I said sometimes calls go through and sometimes not. So I don't think this is due to a wrong configuration on our side or it would just not work.

Do you have access to any kind of logs linked to our prismic repository to see what happens when we're hitting and getting the error?

About the ECONNRESET code :

ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.

Also :

What could also be the case: at random times, the other side is overloaded and simply kills the connection as a result. If that's the case, depends on what you're connecting to exactly…

So it would be interesting to get the API side of things to troubleshoot this issue.

Thanks!

Simon

Yes, the next thing I'll do is check the logs. Could you send me the URL of your repository in a dm, please?

This issue has been closed due to inactivity. Flag to reopen.

Most likely an issue with caching/not updating the master ref.

Just an update from another user's issues.

We were able to fix ETIMEDOUT . Indeed it appeared that the problem was on our side. We use a custom client to query Prismic and it was opening a new TCP connection for each request. This caused timeout issues to create new TCP connections when sending many concurrent requests to Prismic.

We finally solved this by configuring a custom httpAgent with a maxSockets of 30 in order to reuse connections. No more errors and it improved the performance of app.

We still have some ECONNRESET errors from time to time. We solved this problem by just retrying the requests for that kind of error.

disabling vpn did the trick for me