Still getting AggregateErrors after applying all the magic

Abierto
#532 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
docker, nodejs, typescript
Área
api, backend

Línea de trabajo

The report involves openid-client's request helper, the xero-node XeroClient constructor and its clock tolerance setting, plus the per-account locking and sequential token renewal in the consumer's code. No file in the repository is named as the fix point and the reporter's workaround is a sed patch to node_modules, so there is no clear first edit. Done would mean a reproducible cause for the AggregateError under concurrent clients, which needs maintainer input and is not a first-timer task.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

We are still occasionally and nowadays more frequently getting AggregateErrors from the xero api. xero-node is v4.11.3. Connections to all of our client accounts usually break when we get those.

  1. Since xero-node is built on the openid-client but did not / do not support setting a timeout,
    we increased the openid timeout and clock tolerance in our Docker container with a script as a post-processing step.
    RUN sed -i "s/timeout: 2500/timeout: 20000/g" /code/node_modules/openid-client/lib/helpers/request.js
    RUN sed -i "s/this.openIdClient[openid_client_1.custom.clock_tolerance] = 5;/this.openIdClient[openid_client_1.custom.clock_tolerance] = 100;/" /code/node_modules/xero-node/dist/XeroClient.js
    We're also setting Xero.XeroClient() constructor's httpTimeout to 20000.

  2. We avoid creating many Xero.XeroClients using the singleton pattern, but we do create one XeroClient for each of the Xero Accounts we access.

  3. We lock each Xero client while an operation is being executed.
    To make 2. and 3. clear, for example when two of our clients Alice and Bob who have different Xero Accounts want to query their list of xero items, there will be two Xero.XeroClients running the query at the same time. However, if Candice, who is also in Bob's Xero Account wants to query something else, the XeroClient running Bob's query will be locked until Bob's query finishes, then it runs Candice's query.
    So instead of having a single "über" XeroClient for all XeroAccounts and locking that (it would be too slow), we have a XeroClient per Xero Account and locking those. Not sure if this way of having XeroClients is still prone to the AggregateError -- the singleton pattern was proposed by a GitHub user to this specific error.

  4. Tokens for the accounts are renewed sequentially.

Can you please take a closer look or suggest any solution?

Lenguaje dominante
TypeScript
Estrellas
264
Forks
177
Merge medio
10 h 5 min
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de XeroAPI/xero-node

Todos los issues de XeroAPI/xero-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.