@replayci/replay 0.1.0 → 0.1.2
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/dist/index.cjs +49 -13
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +49 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -108,7 +108,11 @@ var CaptureBuffer = class {
|
|
|
108
108
|
if (this.flushPromise) {
|
|
109
109
|
return this.flushPromise;
|
|
110
110
|
}
|
|
111
|
-
const flushPromise = this.flushOnce().catch(() => {
|
|
111
|
+
const flushPromise = this.flushOnce().catch((err) => {
|
|
112
|
+
emitDiagnostics(this.diagnostics, {
|
|
113
|
+
type: "flush_error",
|
|
114
|
+
error: err instanceof Error ? err.message : String(err)
|
|
115
|
+
});
|
|
112
116
|
}).finally(() => {
|
|
113
117
|
if (this.flushPromise === flushPromise) {
|
|
114
118
|
this.flushPromise = void 0;
|
|
@@ -122,9 +126,18 @@ var CaptureBuffer = class {
|
|
|
122
126
|
return;
|
|
123
127
|
}
|
|
124
128
|
this.closed = true;
|
|
125
|
-
this.queue.length = 0;
|
|
126
129
|
this.clearTimer();
|
|
127
|
-
|
|
130
|
+
if (this.queue.length > 0) {
|
|
131
|
+
this.closed = false;
|
|
132
|
+
this.flush().catch(() => {
|
|
133
|
+
}).finally(() => {
|
|
134
|
+
this.closed = true;
|
|
135
|
+
this.queue.length = 0;
|
|
136
|
+
unregisterBuffer(this);
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
unregisterBuffer(this);
|
|
140
|
+
}
|
|
128
141
|
}
|
|
129
142
|
async flushOnce() {
|
|
130
143
|
if (this.closed || this.remoteDisabled || this.queue.length === 0) {
|
|
@@ -186,6 +199,17 @@ var CaptureBuffer = class {
|
|
|
186
199
|
this.failureCount += 1;
|
|
187
200
|
if (this.failureCount >= CIRCUIT_BREAKER_FAILURE_LIMIT) {
|
|
188
201
|
this.circuitOpenUntil = this.now() + CIRCUIT_BREAKER_MS;
|
|
202
|
+
emitDiagnostics(this.diagnostics, {
|
|
203
|
+
type: "circuit_open",
|
|
204
|
+
failures: this.failureCount,
|
|
205
|
+
backoffMs: CIRCUIT_BREAKER_MS
|
|
206
|
+
});
|
|
207
|
+
try {
|
|
208
|
+
console.warn(
|
|
209
|
+
`[replayci] Capture buffer circuit breaker open after ${this.failureCount} consecutive failures. Captures will be dropped for ${CIRCUIT_BREAKER_MS / 6e4} minutes.`
|
|
210
|
+
);
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
189
213
|
this.failureCount = 0;
|
|
190
214
|
}
|
|
191
215
|
}
|
|
@@ -1569,17 +1593,29 @@ function loadContractsFromPaths(inputs) {
|
|
|
1569
1593
|
);
|
|
1570
1594
|
}
|
|
1571
1595
|
});
|
|
1572
|
-
|
|
1596
|
+
const loaded = [];
|
|
1597
|
+
for (const contractFile of contractFiles) {
|
|
1573
1598
|
const contractPath = (0, import_node_path.relative)(repoRoot, contractFile);
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1599
|
+
try {
|
|
1600
|
+
const contract = (0, import_contracts_core2.loadContractSync)({
|
|
1601
|
+
repoRoot,
|
|
1602
|
+
contractPath
|
|
1603
|
+
});
|
|
1604
|
+
loaded.push(normalizeInlineContract({
|
|
1605
|
+
...contract,
|
|
1606
|
+
contract_file: contractFile
|
|
1607
|
+
}));
|
|
1608
|
+
} catch (error) {
|
|
1609
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1610
|
+
if (msg.startsWith("ContractMissingTool:")) {
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1613
|
+
throw new ReplayConfigurationError(
|
|
1614
|
+
`Failed to parse contract "${contractPath}": ${msg}`
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return loaded;
|
|
1583
1619
|
}
|
|
1584
1620
|
function collectContractFiles(inputPath) {
|
|
1585
1621
|
const stat = (0, import_node_fs.statSync)(inputPath);
|
package/dist/index.d.cts
CHANGED
|
@@ -26,6 +26,13 @@ type ObserveDiagnosticEvent = {
|
|
|
26
26
|
} | {
|
|
27
27
|
type: "buffer_overflow";
|
|
28
28
|
dropped: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: "flush_error";
|
|
31
|
+
error: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "circuit_open";
|
|
34
|
+
failures: number;
|
|
35
|
+
backoffMs: number;
|
|
29
36
|
};
|
|
30
37
|
type ObserveOptions = {
|
|
31
38
|
agent?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,13 @@ type ObserveDiagnosticEvent = {
|
|
|
26
26
|
} | {
|
|
27
27
|
type: "buffer_overflow";
|
|
28
28
|
dropped: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: "flush_error";
|
|
31
|
+
error: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "circuit_open";
|
|
34
|
+
failures: number;
|
|
35
|
+
backoffMs: number;
|
|
29
36
|
};
|
|
30
37
|
type ObserveOptions = {
|
|
31
38
|
agent?: string;
|
package/dist/index.js
CHANGED
|
@@ -80,7 +80,11 @@ var CaptureBuffer = class {
|
|
|
80
80
|
if (this.flushPromise) {
|
|
81
81
|
return this.flushPromise;
|
|
82
82
|
}
|
|
83
|
-
const flushPromise = this.flushOnce().catch(() => {
|
|
83
|
+
const flushPromise = this.flushOnce().catch((err) => {
|
|
84
|
+
emitDiagnostics(this.diagnostics, {
|
|
85
|
+
type: "flush_error",
|
|
86
|
+
error: err instanceof Error ? err.message : String(err)
|
|
87
|
+
});
|
|
84
88
|
}).finally(() => {
|
|
85
89
|
if (this.flushPromise === flushPromise) {
|
|
86
90
|
this.flushPromise = void 0;
|
|
@@ -94,9 +98,18 @@ var CaptureBuffer = class {
|
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
100
|
this.closed = true;
|
|
97
|
-
this.queue.length = 0;
|
|
98
101
|
this.clearTimer();
|
|
99
|
-
|
|
102
|
+
if (this.queue.length > 0) {
|
|
103
|
+
this.closed = false;
|
|
104
|
+
this.flush().catch(() => {
|
|
105
|
+
}).finally(() => {
|
|
106
|
+
this.closed = true;
|
|
107
|
+
this.queue.length = 0;
|
|
108
|
+
unregisterBuffer(this);
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
unregisterBuffer(this);
|
|
112
|
+
}
|
|
100
113
|
}
|
|
101
114
|
async flushOnce() {
|
|
102
115
|
if (this.closed || this.remoteDisabled || this.queue.length === 0) {
|
|
@@ -158,6 +171,17 @@ var CaptureBuffer = class {
|
|
|
158
171
|
this.failureCount += 1;
|
|
159
172
|
if (this.failureCount >= CIRCUIT_BREAKER_FAILURE_LIMIT) {
|
|
160
173
|
this.circuitOpenUntil = this.now() + CIRCUIT_BREAKER_MS;
|
|
174
|
+
emitDiagnostics(this.diagnostics, {
|
|
175
|
+
type: "circuit_open",
|
|
176
|
+
failures: this.failureCount,
|
|
177
|
+
backoffMs: CIRCUIT_BREAKER_MS
|
|
178
|
+
});
|
|
179
|
+
try {
|
|
180
|
+
console.warn(
|
|
181
|
+
`[replayci] Capture buffer circuit breaker open after ${this.failureCount} consecutive failures. Captures will be dropped for ${CIRCUIT_BREAKER_MS / 6e4} minutes.`
|
|
182
|
+
);
|
|
183
|
+
} catch {
|
|
184
|
+
}
|
|
161
185
|
this.failureCount = 0;
|
|
162
186
|
}
|
|
163
187
|
}
|
|
@@ -1557,17 +1581,29 @@ function loadContractsFromPaths(inputs) {
|
|
|
1557
1581
|
);
|
|
1558
1582
|
}
|
|
1559
1583
|
});
|
|
1560
|
-
|
|
1584
|
+
const loaded = [];
|
|
1585
|
+
for (const contractFile of contractFiles) {
|
|
1561
1586
|
const contractPath = relative(repoRoot, contractFile);
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1587
|
+
try {
|
|
1588
|
+
const contract = loadContractSync({
|
|
1589
|
+
repoRoot,
|
|
1590
|
+
contractPath
|
|
1591
|
+
});
|
|
1592
|
+
loaded.push(normalizeInlineContract({
|
|
1593
|
+
...contract,
|
|
1594
|
+
contract_file: contractFile
|
|
1595
|
+
}));
|
|
1596
|
+
} catch (error) {
|
|
1597
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1598
|
+
if (msg.startsWith("ContractMissingTool:")) {
|
|
1599
|
+
continue;
|
|
1600
|
+
}
|
|
1601
|
+
throw new ReplayConfigurationError(
|
|
1602
|
+
`Failed to parse contract "${contractPath}": ${msg}`
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return loaded;
|
|
1571
1607
|
}
|
|
1572
1608
|
function collectContractFiles(inputPath) {
|
|
1573
1609
|
const stat = statSync(inputPath);
|