Looker API returns an unpredictable ECONNRESET

nem
Bronze 2
Bronze 2

The following code will sometimes, return ECONNRESET:

 

const params = {
  model: ...,
  view: ...,
  fields: [...],
};
const query = await sdk.ok(sdk.create_query(params));
const runParams = {
  query_id: query.id,
  limit: 1
}
const result = await sdk.ok(sdk.run_query(runParams)) // <-- ECONNRESET

 

The thing is, there doesn't seem to be an obvious pattern to the problem and Looker API doesn't provide any clues.

Because each invocation in our system is distinct, we don't use an .ini file or env vars, and instead authenticate with Looker on the fly for each request, like this:

 

const settings = new ApiSettings({
  base_url: request.looker_base_url,
});
settings.readConfig = () => {
  const cfg = {
    base_url: request.looker_base_url,
    client_id: request.looker_client_id,
    client_secret: request.looker_client_secret,
    verify_ssl: true,
    timeout: 120,
  };
  return cfg;
};
const sdk = LookerNodeSDK.init40(settings);

 

 Does anyone have advice on what the issue might be?

0 2 108
2 REPLIES 2

nem
Bronze 2
Bronze 2

I managed to isolate the issue to a single endpoint and am able to consistently reproduce it.

The erroring URL is a GET request to /queries/:query_id/run/json_bi?limit=1, like this:

GET https://$OBFUSCATED.looker.com:19999/api/4.0/queries/751560/run/json_bi?limit=1

 After digging into the Looker SDK code base, the error returned is:

{
  "name": "RequestError",
  "message": "Error: socket hang up",
  "cause": {
    "code": "ECONNRESET"
  },
  "error": {
    "code": "ECONNRESET"
  },
  "options": {
    "encoding": null,
    "headers": {
      "x-looker-appid": "...",
      "Authorization": "Bearer $OBFUSCATED$"
    },
    "json": null,
    "method": "GET",
    "rejectUnauthorized": true,
    "resolveWithFullResponse": true,
    "timeout": 120000,
    "url": "https://$OBFUSCATED.looker.com:19999/api/4.0/queries/751560/run/json_bi?limit=1"
    "simple": true,
    "transform2xxOnly": false
  }
}

 And the erroring code is: https://github.com/looker-open-source/sdk-codegen/blob/13f209c21d9de234a787f95f8d2ce61a73bd203d/pack...

On further inspection, it seems that the "json_bi" format is the issue.

Using the "json" format doesn't lead to ECONNRESET while using "json_bi" does.

This is quite strange but I am able to reproduce the results (tried 5 times).

Confusingly, "json_bi" is the recommended format even though it leads to an obfuscated issue like this.

bug.png

This works:

GET /api/4.0/queries/:query_id/run/json

This throws ECONNRESET each time:

GET /api/4.0/queries/:query_id/run/json_bi