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.