@devlas/dte-sii 2.9.7 → 2.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/EnviadorSII.js +10 -0
  2. package/package.json +1 -1
package/EnviadorSII.js CHANGED
@@ -192,6 +192,8 @@ class EnviadorSII {
192
192
  </soapenv:Envelope>`;
193
193
 
194
194
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
195
+ const controller = new AbortController();
196
+ const soapTimeout = setTimeout(() => controller.abort(), getConfigSection('timeout')?.soap || 30000);
195
197
  try {
196
198
  if (attempt > 1) {
197
199
  log.log(` [...] Reintento semilla SOAP ${attempt}/${maxRetries}...`);
@@ -205,7 +207,9 @@ class EnviadorSII {
205
207
  'SOAPAction': '',
206
208
  },
207
209
  body: soapEnvelope,
210
+ signal: controller.signal,
208
211
  });
212
+ clearTimeout(soapTimeout);
209
213
 
210
214
  if (!response.ok) {
211
215
  if (isRetryableStatus(response.status) && attempt < maxRetries) {
@@ -232,6 +236,7 @@ class EnviadorSII {
232
236
 
233
237
  throw siiError('No se pudo extraer semilla de la respuesta SOAP', ERROR_CODES.SII_INVALID_RESPONSE);
234
238
  } catch (error) {
239
+ clearTimeout(soapTimeout);
235
240
  if (isRetryableError(error) && attempt < maxRetries) {
236
241
  log.log(` [!] Error de conexión semilla SOAP (${error.cause?.code || 'socket'}), reintentando...`);
237
242
  continue;
@@ -264,6 +269,8 @@ class EnviadorSII {
264
269
  const url = this.urls[this.ambiente].tokenSoap;
265
270
 
266
271
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
272
+ const controller = new AbortController();
273
+ const soapTimeout = setTimeout(() => controller.abort(), getConfigSection('timeout')?.soap || 30000);
267
274
  try {
268
275
  if (attempt > 1) {
269
276
  log.log(` [...] Reintento token SOAP ${attempt}/${maxRetries}...`);
@@ -289,7 +296,9 @@ class EnviadorSII {
289
296
  'SOAPAction': '',
290
297
  },
291
298
  body: soapEnvelope,
299
+ signal: controller.signal,
292
300
  });
301
+ clearTimeout(soapTimeout);
293
302
 
294
303
  if (!response.ok) {
295
304
  const errorText = await response.text();
@@ -328,6 +337,7 @@ class EnviadorSII {
328
337
 
329
338
  throw siiError('No se pudo obtener token SOAP del SII', ERROR_CODES.SII_INVALID_RESPONSE);
330
339
  } catch (error) {
340
+ clearTimeout(soapTimeout);
331
341
  if (isRetryableError(error) && attempt < maxRetries) {
332
342
  log.log(` [!] Error de conexión token SOAP (${error.cause?.code || 'socket'}), reintentando...`);
333
343
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlas/dte-sii",
3
- "version": "2.9.7",
3
+ "version": "2.9.8",
4
4
  "description": "Facturación y boletas electrónicas para el SII de Chile. Genera, timbra, firma y envía DTEs, libros electrónicos y automatiza la certificación.",
5
5
  "main": "index.js",
6
6
  "types": "dte-sii.d.ts",