question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Queries keep timing out

See original GitHub issue

Hey there,

For some reason and quite often our calls to the API fail with a ETIMEDOUT. The application runs on a Azure Web App using node-iis. Depending on the resource, a lot of concurrent queries can occur, as we are trying to fetch nested references (imagine a navigation) or a slice that references a different resource.

Here are some examples of the errors:

(node:5748) UnhandledPromiseRejectionWarning: FetchError: request to https://xxx.cdn.prismic.io/api/v2 failed, reason: connect ETIMEDOUT 54.192.27.125:443
    at ClientRequest.<anonymous> (D:\home\site\wwwroot\node_modules\node-fetch\index.js:133:11)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

or

(node:5748) UnhandledPromiseRejectionWarning: FetchError: request to https://xxx.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=100&lang=it-ch&ref=....&q=%5B%5Bany(document.type%2C%20%5B%22default_page%22%2C%22empty_page%22%2C%22communities_page%22%2C%22home_page%22%2C%22ranking_page%22%2C%22sponsors_page%22%5D)%5D%5D failed, reason: connect ETIMEDOUT 54.192.27.125:443
    at ClientRequest.<anonymous> (D:\home\site\wwwroot\node_modules\node-fetch\index.js:133:11)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

These are just some examples and I wasn’t able to reproduce them. For every incoming request we initialize the API and reuse that API throughout the request.

Do you have any ideas what could cause this problem? Is there something I can do? Is it possible to set a keep alive agent for the requests to your API?

I am interested to see what you guys think. I haven’t found any way yet, to resolve this issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
madeleineostojacommented, Jun 6, 2019

I’m seeing this too, did anyone find out what’s going on, or a potential fix? For me it started when the resource I was requesting (documents with a certain type) exceeded around 25 items.

0reactions
arnaudlewiscommented, Jan 6, 2020

This shouldn’t happen by default because we rely on the default implementation of the HttpAgent that allows you to have enough opened connection. If you use a proxy and need to implement your own HttpAgent, you need to setup enough sockets and use the keepalive option to keep to connection open if you have a lot of concurrent calls.

const httpAgent = new HttpAgent({		
   keepAlive: true,		
   maxSockets: 20,		
 });

It would look like this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot query time-out errors - SQL Server
A query time-out is different from a connection time-out or login time-out. The connection or login timeout occurs when the initial connection ...
Read more >
SQL query timing out but previously working fine | OutSystems
The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated."
Read more >
How to Troubleshoot Intermittent SQL Timeout Errors
Run SQL trace of long running queries and deadlocks. · Use performance monitor to track connection pool connections. · Separate web applications ...
Read more >
MS Access 2003: Prevent a query from timing out
This MSAccess tutorial explains how to prevent a query from timing out in Access 2003 (with screenshots and step-by-step instructions).
Read more >
How to Increase the MS SQL Remote Query Timeout?
MS SQL Server has an option called Remote Query Timeout to specify the time (in seconds), a remote operation can take before SQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found