@blaxel/core 0.3.11 → 0.3.12-preview.250

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.
@@ -47,6 +47,7 @@ const DEFAULT_PING_TIMEOUT_MS = 500;
47
47
  class H2Pool {
48
48
  sessions = new Map();
49
49
  inflight = new Map();
50
+ validations = new Map();
50
51
  _establish = null;
51
52
  maxIdleMs;
52
53
  pingTimeoutMs;
@@ -120,26 +121,39 @@ class H2Pool {
120
121
  return Promise.resolve(false);
121
122
  return new Promise((resolve) => {
122
123
  let settled = false;
123
- const finish = (ok) => {
124
+ const finish = (shouldRetain) => {
124
125
  if (settled)
125
126
  return;
126
127
  settled = true;
127
128
  clearTimeout(timer);
128
- resolve(ok);
129
+ resolve(shouldRetain);
129
130
  };
130
131
  const timer = setTimeout(() => finish(false), this.pingTimeoutMs);
131
132
  try {
132
133
  const sent = session.ping((err) => {
133
134
  finish(!err && !this.isClosed(session));
134
135
  });
136
+ // `false` means Node did not send the ping, not that the session failed.
135
137
  if (!sent)
136
- finish(false);
138
+ finish(true);
137
139
  }
138
140
  catch {
139
141
  finish(false);
140
142
  }
141
143
  });
142
144
  }
145
+ validateSession(domain, session) {
146
+ const existing = this.validations.get(domain);
147
+ if (existing?.session === session)
148
+ return existing.promise;
149
+ const promise = this.ping(session).finally(() => {
150
+ if (this.validations.get(domain)?.promise === promise) {
151
+ this.validations.delete(domain);
152
+ }
153
+ });
154
+ this.validations.set(domain, { session, promise });
155
+ return promise;
156
+ }
143
157
  async validateEntry(domain, entry) {
144
158
  if (!entry)
145
159
  return null;
@@ -152,9 +166,10 @@ class H2Pool {
152
166
  this.markUsed(domain, session);
153
167
  return session;
154
168
  }
155
- if (await this.ping(session)) {
156
- // ENG-2676 generation/identity pin: `await this.ping` yields, and during
157
- // that await an eviction listener (goaway/error/close ->
169
+ const shouldRetain = await this.validateSession(domain, session);
170
+ if (shouldRetain && !this.isClosed(session)) {
171
+ // ENG-2676 generation/identity pin: validation yields, and during that
172
+ // await an eviction listener (goaway/error/close ->
158
173
  // attachEvictionListeners, see above) may have deleted or replaced this
159
174
  // entry. `entry` is the exact object held in the map, so if it is no
160
175
  // longer the cached generation, refuse the now-stale session instead of
@@ -255,6 +270,7 @@ class H2Pool {
255
270
  }
256
271
  this.sessions.clear();
257
272
  this.inflight.clear();
273
+ this.validations.clear();
258
274
  }
259
275
  }
260
276
  exports.H2Pool = H2Pool;
@@ -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.11";
34
- const BUILD_COMMIT = "2f0b2eea01b33051dbb8b73fed58f043aed16ed0";
33
+ const BUILD_VERSION = "0.3.12-preview.250";
34
+ const BUILD_COMMIT = "2dfbef5e25645893d88eff71732af77cdc781565";
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
@@ -16,6 +16,7 @@ export type H2PoolOptions = {
16
16
  export declare class H2Pool {
17
17
  private sessions;
18
18
  private inflight;
19
+ private validations;
19
20
  private _establish;
20
21
  private readonly maxIdleMs;
21
22
  private readonly pingTimeoutMs;
@@ -38,6 +39,7 @@ export declare class H2Pool {
38
39
  private markUsed;
39
40
  private evict;
40
41
  private ping;
42
+ private validateSession;
41
43
  private validateEntry;
42
44
  /**
43
45
  * Fire-and-forget background warming. Safe to call multiple times for