tracereports 0.1.2 → 0.3.0
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.
- package/README.es.md +15 -0
- package/README.md +15 -0
- package/package.json +3 -2
- package/src/binary.js +125 -0
- package/src/env.js +8 -5
- package/src/index.d.ts +31 -1
- package/src/index.js +232 -19
- package/src/mirror.js +173 -0
- package/src/offline.js +132 -0
- package/src/playwright.js +39 -1
- package/src/reporter.js +20 -5
- package/src/selenium.js +193 -7
- package/src/transport.js +31 -3
package/src/transport.js
CHANGED
|
@@ -33,6 +33,7 @@ export class Sender {
|
|
|
33
33
|
this.downUntil = 0;
|
|
34
34
|
this.running = false;
|
|
35
35
|
this.waiters = [];
|
|
36
|
+
this.pause = null; // backoff en curso: {timer, wake}, para que abandon() lo corte
|
|
36
37
|
this.stats = { sent: 0, retried: 0, rejected: 0, dropped: 0, lost: 0 };
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -118,7 +119,7 @@ export class Sender {
|
|
|
118
119
|
item.attempts++;
|
|
119
120
|
this.stats.retried++;
|
|
120
121
|
this.queue.unshift(item);
|
|
121
|
-
await
|
|
122
|
+
await this.backoff(Math.min(limits.maxBackoffMs, 500 * 2 ** Math.min(item.attempts, 6)));
|
|
122
123
|
continue;
|
|
123
124
|
}
|
|
124
125
|
this.bytes -= item.size;
|
|
@@ -134,10 +135,30 @@ export class Sender {
|
|
|
134
135
|
for (const w of this.waiters.splice(0)) w();
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
/** Espera
|
|
138
|
+
/** Espera de un reintento que abandon() puede cortar (si no, mantendría vivo el proceso). */
|
|
139
|
+
backoff(ms) {
|
|
140
|
+
return new Promise((wake) => {
|
|
141
|
+
const timer = setTimeout(() => { this.pause = null; wake(); }, ms);
|
|
142
|
+
this.pause = { timer, wake };
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Espera a que la cola se vacíe (máx. timeoutMs). Devuelve lo que quedó pendiente. Lo que gana
|
|
148
|
+
* cancela lo otro: si se vacía, el temporizador del timeout se borra (no retiene el proceso);
|
|
149
|
+
* si vence, el waiter sale de la lista.
|
|
150
|
+
*/
|
|
138
151
|
async flush(timeoutMs) {
|
|
139
152
|
if (!this.pending) return 0;
|
|
140
|
-
|
|
153
|
+
let timer, waiter;
|
|
154
|
+
await new Promise((resolve) => {
|
|
155
|
+
waiter = resolve;
|
|
156
|
+
this.waiters.push(waiter);
|
|
157
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
158
|
+
});
|
|
159
|
+
clearTimeout(timer);
|
|
160
|
+
const i = this.waiters.indexOf(waiter);
|
|
161
|
+
if (i >= 0) this.waiters.splice(i, 1);
|
|
141
162
|
return this.pending;
|
|
142
163
|
}
|
|
143
164
|
|
|
@@ -149,6 +170,13 @@ export class Sender {
|
|
|
149
170
|
this.inflight = null;
|
|
150
171
|
this.bytes = 0;
|
|
151
172
|
this.stats.lost += items.length;
|
|
173
|
+
// nada queda esperando: el backoff en curso termina ya y los flush pendientes vuelven
|
|
174
|
+
if (this.pause) {
|
|
175
|
+
clearTimeout(this.pause.timer);
|
|
176
|
+
this.pause.wake();
|
|
177
|
+
this.pause = null;
|
|
178
|
+
}
|
|
179
|
+
this.notify();
|
|
152
180
|
if (items.length) {
|
|
153
181
|
console.warn(`tracereports: ${items.length} eventos de evidencia no se pudieron enviar y se perdieron`);
|
|
154
182
|
}
|