@blaxel/core 0.3.12-preview.253 → 0.3.12-preview.255
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/h2fetch.js +7 -0
- package/dist/cjs/common/h2pool.js +19 -21
- package/dist/cjs/common/h2stats.js +115 -0
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/types/common/h2pool.d.ts +1 -0
- package/dist/cjs/types/common/h2stats.d.ts +17 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/h2stats.js +115 -0
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/types/common/h2pool.d.ts +1 -0
- package/dist/cjs-browser/types/common/h2stats.d.ts +17 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/h2fetch.js +7 -0
- package/dist/esm/common/h2pool.js +19 -21
- package/dist/esm/common/h2stats.js +109 -0
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/h2stats.js +109 -0
- package/dist/esm-browser/common/settings.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snapshotH2TransportStats = snapshotH2TransportStats;
|
|
4
|
+
exports.resetH2TransportStats = resetH2TransportStats;
|
|
5
|
+
exports.recordH2EstablishFailure = recordH2EstablishFailure;
|
|
6
|
+
exports.recordH2Fallback = recordH2Fallback;
|
|
7
|
+
const logger_js_1 = require("./logger.js");
|
|
8
|
+
const emptyReasons = () => ({
|
|
9
|
+
"no-session": 0,
|
|
10
|
+
"request-rejected": 0,
|
|
11
|
+
"session-unusable": 0,
|
|
12
|
+
"unsupported-body": 0,
|
|
13
|
+
});
|
|
14
|
+
const MAX_TRACKED_DOMAINS = 100;
|
|
15
|
+
const H2_DEBUG_STATS_SYMBOL = Symbol.for("blaxel.h2stats");
|
|
16
|
+
const h2DebugStatsEnabled = typeof process !== "undefined" && process.env?.BL_H2_DEBUG_STATS === "1";
|
|
17
|
+
function publishDebugSnapshot(snapshot) {
|
|
18
|
+
if (!h2DebugStatsEnabled)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
globalThis[H2_DEBUG_STATS_SYMBOL] = snapshot;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Debug diagnostics must never change transport behavior.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const emptyDomainStats = () => ({
|
|
28
|
+
establishFailures: 0,
|
|
29
|
+
fetchFallbacks: 0,
|
|
30
|
+
fallbacksByReason: emptyReasons(),
|
|
31
|
+
});
|
|
32
|
+
class H2TransportStatsStore {
|
|
33
|
+
totals = emptyDomainStats();
|
|
34
|
+
byDomain = new Map();
|
|
35
|
+
snapshot() {
|
|
36
|
+
return {
|
|
37
|
+
...this.clone(this.totals),
|
|
38
|
+
byDomain: Object.fromEntries([...this.byDomain].map(([domain, stats]) => [domain, this.clone(stats)])),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
reset() {
|
|
42
|
+
this.totals = emptyDomainStats();
|
|
43
|
+
this.byDomain.clear();
|
|
44
|
+
publishDebugSnapshot(this.snapshot());
|
|
45
|
+
}
|
|
46
|
+
/** @internal */
|
|
47
|
+
recordEstablishFailure(domain, error) {
|
|
48
|
+
this.totals.establishFailures++;
|
|
49
|
+
this.forDomain(domain).establishFailures++;
|
|
50
|
+
try {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
logger_js_1.logger.debug(`H2 session establishment failed for ${domain}: ${message}`);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Diagnostics must never change transport behavior.
|
|
56
|
+
}
|
|
57
|
+
publishDebugSnapshot(this.snapshot());
|
|
58
|
+
}
|
|
59
|
+
/** @internal */
|
|
60
|
+
recordFallback(domain, reason) {
|
|
61
|
+
this.totals.fetchFallbacks++;
|
|
62
|
+
this.totals.fallbacksByReason[reason]++;
|
|
63
|
+
const stats = this.forDomain(domain);
|
|
64
|
+
stats.fetchFallbacks++;
|
|
65
|
+
stats.fallbacksByReason[reason]++;
|
|
66
|
+
try {
|
|
67
|
+
logger_js_1.logger.debug(`H2 transport falling back to fetch for ${domain}: ${reason}`);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Diagnostics must never change transport behavior.
|
|
71
|
+
}
|
|
72
|
+
publishDebugSnapshot(this.snapshot());
|
|
73
|
+
}
|
|
74
|
+
forDomain(domain) {
|
|
75
|
+
let stats = this.byDomain.get(domain);
|
|
76
|
+
if (stats) {
|
|
77
|
+
this.byDomain.delete(domain);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (this.byDomain.size >= MAX_TRACKED_DOMAINS) {
|
|
81
|
+
const oldest = this.byDomain.keys().next().value;
|
|
82
|
+
if (oldest !== undefined)
|
|
83
|
+
this.byDomain.delete(oldest);
|
|
84
|
+
}
|
|
85
|
+
stats = emptyDomainStats();
|
|
86
|
+
}
|
|
87
|
+
this.byDomain.set(domain, stats);
|
|
88
|
+
return stats;
|
|
89
|
+
}
|
|
90
|
+
clone(stats) {
|
|
91
|
+
return {
|
|
92
|
+
establishFailures: stats.establishFailures,
|
|
93
|
+
fetchFallbacks: stats.fetchFallbacks,
|
|
94
|
+
fallbacksByReason: { ...stats.fallbacksByReason },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const store = new H2TransportStatsStore();
|
|
99
|
+
publishDebugSnapshot(store.snapshot());
|
|
100
|
+
/** @internal */
|
|
101
|
+
function snapshotH2TransportStats() {
|
|
102
|
+
return store.snapshot();
|
|
103
|
+
}
|
|
104
|
+
/** @internal */
|
|
105
|
+
function resetH2TransportStats() {
|
|
106
|
+
store.reset();
|
|
107
|
+
}
|
|
108
|
+
/** @internal */
|
|
109
|
+
function recordH2EstablishFailure(domain, error) {
|
|
110
|
+
store.recordEstablishFailure(domain, error);
|
|
111
|
+
}
|
|
112
|
+
/** @internal */
|
|
113
|
+
function recordH2Fallback(domain, reason) {
|
|
114
|
+
store.recordFallback(domain, reason);
|
|
115
|
+
}
|
|
@@ -30,8 +30,8 @@ function missingCredentialsMessage() {
|
|
|
30
30
|
return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
|
|
31
31
|
}
|
|
32
32
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
33
|
-
const BUILD_VERSION = "0.3.12-preview.
|
|
34
|
-
const BUILD_COMMIT = "
|
|
33
|
+
const BUILD_VERSION = "0.3.12-preview.255";
|
|
34
|
+
const BUILD_COMMIT = "0a7ecff86c697285b849e61a8cc5219e85b5ba89";
|
|
35
35
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
36
36
|
const BLAXEL_API_VERSION = "2026-04-28";
|
|
37
37
|
// Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type H2FallbackReason = "no-session" | "request-rejected" | "session-unusable" | "unsupported-body";
|
|
2
|
+
export type H2TransportDomainStats = {
|
|
3
|
+
establishFailures: number;
|
|
4
|
+
fetchFallbacks: number;
|
|
5
|
+
fallbacksByReason: Record<H2FallbackReason, number>;
|
|
6
|
+
};
|
|
7
|
+
export type H2TransportStatsSnapshot = H2TransportDomainStats & {
|
|
8
|
+
byDomain: Record<string, H2TransportDomainStats>;
|
|
9
|
+
};
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare function snapshotH2TransportStats(): H2TransportStatsSnapshot;
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare function resetH2TransportStats(): void;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function recordH2EstablishFailure(domain: string, error: unknown): void;
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare function recordH2Fallback(domain: string, reason: H2FallbackReason): void;
|