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