Intermittent API endpoint timeouts

Hi there support crew,

My team and I are running into occasional /api/v2 outages when attempting to create a new instance of the Prismic JS client.

We're using Nuxt as well as the @nuxtjs/prismic module.

Both locally and on our Netlify build pipeline, we're seeing this error:

[error] request to https://<repository_name>.prismic.io/api/v2 failed, reason: connect ETIMEDOUT 3.226.167.146:443

...which in turn causes the client instance to not be created, leading to further errors:

[error] Failed to init Prismic API, preventing app fatal error.

and

TypeError: $prismic.api.getByUID is not a function

Please let me know if I can supply any additional information!

1 Like

Hey @aaron1 ,

Thanks for posting this error! I haven't seen this one specifically before, but I have one suggestion off the top of my head: It looks like you're not using the CDN endpoint. Try reformatting your endpoint like this:

https://<repository_name>.cdn.prismic.io/api/v2

And see if that helps.

If that's not the issue, I can talk to our engineering team.

Sam

1 Like

Ah that's a great point, thank you Sam!

I will update the endpoint to include the CDN subdomain and let you know if we run into further issues with timeouts.

1 Like

Great! Thanks, @aaron1

Hi @samlittlefair, we had a blip yesterday evening with an ECONNRESET error:

During nuxt generate, we ran into this error:

[fatal] request to https://<repo_name>.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=100&ref=<ref_here>&q=%5B%5Bat(document.type%2C%20%22journal_entry%22)%5D%5D failed, reason: read ECONNRESET

I obfuscated our repo name and the ref, but that's a verbatim paste from Netlify build logs.

Any ideas about what could cause a ECONNRESET, and if it's something we should guard against (i.e. auto-retry in our Netlify builds, etc?)

Hey @aaron1

I have indeed seen a similar error with nuxt generate. At the time, I offered these troubleshooting steps:

If I remember correctly, it seemed like it might be a problem with making 1000s of requests server-side.

Let me know if any of those troubleshooting steps help or not.

Sam

Hi @samlittlefair, after adding some logging, I can confirm this is occurring (occasionally) during the first query to the API, where only a single page of 100 results is being returned:

return await $prismic.api.query(
  $prismic.predicates.at('document.type', 'journal_entry'),
  { pageSize: 100 }
)

Hi @aaron1 ,

Could you send me your project files, either in a GitHub repo or ZIP file? If so, I can take a closer look to see if I can find a cause of the error.

Sam

PS: I'll be out on Monday and Tuesday, so I probably won't get to respond until Wednesday.

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

I'm experiencing the same issue as the OP. It doesn't always happen but I get this error from time to time, specially when using the similar query but we only query 6 records at a time with a maxResults of 10. Is there anyway to check the logs on prismic side?

Hello @levijesica, we haven't detected any irregularities in the API. Are you still experiencing this error?

You can always check our status page if necessary:

https://status.prismic.io/

yes, the error happens from time to time but the error says that the server is not reachable

Can you share any logs that you see in the console?

Getting timeouts

9:22:05 PM: [error] /club-journal/mexico-city-event-recap/
9:22:05 PM:
9:22:05 PM: FetchError: request to https://exclusiveresorts.cdn.prismic.io/api/v2?access_token=ailed, reason: connect ETIMEDOUT 108.156.172.10:443
9:22:05 PM: at ClientRequest. (/opt/build/repo/node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:1491:11)
9:22:05 PM: at ClientRequest.emit (node:events:513:28)
9:22:05 PM: at TLSSocket.socketErrorListener (node:_http_client:494:9)
9:22:05 PM: at TLSSocket.emit (node:events:513:28)
9:22:05 PM: at emitErrorNT (node:internal/streams/destroy:157:8)
9:22:05 PM: at emitErrorCloseNT (node:internal/streams/destroy:122:3)
9:22:05 PM: at processTicksAndRejections (node:internal/process/task_queues:83:21)
9:22:05 PM: [error] request to https://exclusiveresorts.cdn.prismic.io/api/v2?access_token== failed, reason: connect ETIMEDOUT 108.156.172.10:443
9:22:05 PM: at ClientRequest. (node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:1491:11)
9:22:05 PM: at ClientRequest.emit (node:events:513:28)
9:22:05 PM: at TLSSocket.socketErrorListener (node:_http_client:494:9)
9:22:05 PM: at TLSSocket.emit (node:events:513:28)
9:22:05 PM: at emitErrorNT (node:internal/streams/destroy:157:8)
9:22:05 PM: at emitErrorCloseNT (node:internal/streams/destroy:122:3)
9:22:05 PM: at processTicksAndRejections (node:internal/process/task_queues:83:21)
9:22:05 PM: [success] Generated route "/residences/nantucket-massachusetts/"
9:22:05 PM: [success] Generated route "/residences/new-york-city-new-york/"
9:22:05 PM: [success] Generated route "/residences/london-england/"
9:22:06 PM: [success] Generated route "/residences/peninsula-papagayo-costa-rica/"
9:22:06 PM: [success] Generated route "/residences/phuket-thailand/"
9:22:06 PM: [success] Generated route "/residences/st-barts-french-west-indies/"
9:22:06 PM: [success] Generated route "/residences/sun-valley-idaho/"
9:22:06 PM: [success] Generated route "/residences/sonoma-california/"
9:22:07 PM: [success] Generated route "/residences/puglia-italy/"
9:22:07 PM: [success] Generated route "/residences/steamboat-springs-colorado/"
9:22:07 PM: [success] Generated route "/residences/telluride-colorado/"
9:22:07 PM: [success] Generated route "/residences/newport-beach-california/"
9:22:07 PM: [success] Generated route "/residences/snowmass-colorado/"
9:22:08 PM: [success] Generated route "/residences/vabbinfaru-maldives/"
9:22:08 PM: [success] Generated route "/residences/nendaz-switzerland/"
9:22:08 PM: [success] Generated route "/residences/nassau-bahamas/"
9:22:08 PM: [success] Generated route "/residences/lake-como-italy/"
9:22:08 PM: [success] Generated route "/residences/istanbul-turkey/"
9:22:09 PM: [success] Generated route "/residences/lang-co-vietnam/"
9:22:09 PM: [success] Generated route "/residences/ibiza-spain/"
9:22:09 PM: [success] Generated route "/residences/las-vegas-nevada/"

Thanks for the information. I'll send it to the dev team. I'll let you know what we find.

Hey @williambell9708, which platform are you using (e.g. Netlify)?