@blaxel/core 0.2.87-preview.168 → 0.2.87-preview.170
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 +55 -52
- package/dist/cjs/common/h2pool.js +9 -0
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/types/common/h2fetch.d.ts +9 -4
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/types/common/h2fetch.d.ts +9 -4
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/h2fetch.js +55 -52
- package/dist/esm/common/h2pool.js +9 -0
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/package.json +1 -1
|
@@ -103,64 +103,44 @@ function createH2Fetch(session) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* The single HTTP/2 request gateway (ENG-2679).
|
|
107
107
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
108
|
+
* Every pool-backed request funnels through here, no matter which entry point
|
|
109
|
+
* it came from: the generated client's fetch (`createPoolBackedH2Fetch`),
|
|
110
|
+
* `SandboxAction.h2Fetch`, and the interpreter's direct path (both via
|
|
111
|
+
* `h2RequestDirectFromPool`). It owns the shared request lifecycle in one place:
|
|
112
|
+
* 1. take a per-domain open-stream slot,
|
|
113
|
+
* 2. get a live session from the pool,
|
|
114
|
+
* 3. send the request on it,
|
|
115
|
+
* 4. evict the session if the send fails after a stream was opened,
|
|
116
|
+
* 5. fall back to globalThis.fetch when the pool has no usable session.
|
|
117
|
+
*
|
|
118
|
+
* This is the chokepoint where reliability behavior that must protect EVERY
|
|
119
|
+
* consumer belongs: the open-stream concurrency limit today, and retry,
|
|
120
|
+
* timeouts, typed errors, and observability in later phases. Adding it once here
|
|
121
|
+
* (instead of re-implementing it per entry point) is what stops the recurring
|
|
122
|
+
* "fixed on one path, still broken on another" regressions.
|
|
123
|
+
*
|
|
124
|
+
* `send` performs the actual wire send on a live session; the caller supplies it
|
|
125
|
+
* so the gateway stays agnostic to the `Request` vs `(url, init)` call shapes,
|
|
126
|
+
* and it receives the slot-release and request-created hooks. `fallback` runs
|
|
127
|
+
* only when the pool has no usable session (a fresh connection, no shared
|
|
128
|
+
* stream is opened).
|
|
111
129
|
*/
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// below are safe even though the send path may also release.
|
|
120
|
-
const rel = await acquireH2Slot(domain);
|
|
121
|
-
try {
|
|
122
|
-
const session = await pool.get(domain);
|
|
123
|
-
if (session) {
|
|
124
|
-
let h2RequestCreated = false;
|
|
125
|
-
try {
|
|
126
|
-
return await _h2Request(session, input, {
|
|
127
|
-
onH2RequestCreated: () => {
|
|
128
|
-
h2RequestCreated = true;
|
|
129
|
-
},
|
|
130
|
-
releaseSlot: rel,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
catch (err) {
|
|
134
|
-
if (h2RequestCreated) {
|
|
135
|
-
pool.evictSession(domain, session);
|
|
136
|
-
}
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// No usable session: this fetch does not open a stream on the shared
|
|
141
|
-
// session, so free the slot before falling back.
|
|
142
|
-
rel();
|
|
143
|
-
return await globalThis.fetch(input);
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
// Pre-send throw (e.g. pool.get() or Request body read): release the slot
|
|
147
|
-
// so a failed request never pins it. Idempotent if already released.
|
|
148
|
-
rel();
|
|
149
|
-
throw err;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
async function h2RequestDirectFromPool(pool, domain, url, init) {
|
|
154
|
-
// See createPoolBackedH2Fetch: the slot is held for the OPEN-STREAM lifetime
|
|
155
|
-
// and released by the send path on the stream terminal; non-stream fallbacks
|
|
156
|
-
// release it immediately. `rel` is idempotent.
|
|
130
|
+
async function h2GatewayRequest(pool, domain, send, fallback) {
|
|
131
|
+
// Take the slot here, but hand its release to the send path: it is held for
|
|
132
|
+
// the OPEN-STREAM lifetime and freed on the stream terminal (ENG-2678). A
|
|
133
|
+
// request that never opens a stream on the shared session (the fallback goes
|
|
134
|
+
// over a different connection) releases it immediately so it does not count
|
|
135
|
+
// against the open-stream budget. `rel` is idempotent, so releasing here when
|
|
136
|
+
// the send path may also release is safe.
|
|
157
137
|
const rel = await acquireH2Slot(domain);
|
|
158
138
|
try {
|
|
159
139
|
const session = await pool.get(domain);
|
|
160
140
|
if (session) {
|
|
161
141
|
let h2RequestCreated = false;
|
|
162
142
|
try {
|
|
163
|
-
return await
|
|
143
|
+
return await send(session, {
|
|
164
144
|
onH2RequestCreated: () => {
|
|
165
145
|
h2RequestCreated = true;
|
|
166
146
|
},
|
|
@@ -168,21 +148,44 @@ async function h2RequestDirectFromPool(pool, domain, url, init) {
|
|
|
168
148
|
});
|
|
169
149
|
}
|
|
170
150
|
catch (err) {
|
|
151
|
+
// A failure AFTER a stream opened means the session is suspect: drop it
|
|
152
|
+
// so the next caller gets a fresh one.
|
|
171
153
|
if (h2RequestCreated) {
|
|
172
154
|
pool.evictSession(domain, session);
|
|
173
155
|
}
|
|
174
156
|
throw err;
|
|
175
157
|
}
|
|
176
158
|
}
|
|
177
|
-
// No usable session:
|
|
159
|
+
// No usable session: free the slot before falling back over a different
|
|
160
|
+
// connection (no stream opens on the shared session).
|
|
178
161
|
rel();
|
|
179
|
-
return await
|
|
162
|
+
return await fallback();
|
|
180
163
|
}
|
|
181
164
|
catch (err) {
|
|
165
|
+
// Pre-send throw (pool.get(), Request body read, or the fallback itself):
|
|
166
|
+
// release the slot so a failed request never pins it. Idempotent.
|
|
182
167
|
rel();
|
|
183
168
|
throw err;
|
|
184
169
|
}
|
|
185
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Creates a fetch()-compatible function backed by the H2 session pool, routed
|
|
173
|
+
* through the single gateway. Used as the generated client's `fetch`.
|
|
174
|
+
*
|
|
175
|
+
* If no usable H2 session is available, the request falls back to regular fetch
|
|
176
|
+
* before any H2 frames are sent.
|
|
177
|
+
*/
|
|
178
|
+
function createPoolBackedH2Fetch(pool, domain) {
|
|
179
|
+
return (input) => h2GatewayRequest(pool, domain, (session, options) => _h2Request(session, input, options), () => globalThis.fetch(input));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Pool-backed H2 request taking raw url + init (skips Request allocation),
|
|
183
|
+
* routed through the same single gateway. Used by `SandboxAction.h2Fetch` and
|
|
184
|
+
* the code interpreter.
|
|
185
|
+
*/
|
|
186
|
+
function h2RequestDirectFromPool(pool, domain, url, init) {
|
|
187
|
+
return h2GatewayRequest(pool, domain, (session, options) => h2RequestDirectInternal(session, url, init, options), () => globalThis.fetch(url, init));
|
|
188
|
+
}
|
|
186
189
|
/**
|
|
187
190
|
* Low-level H2 request that takes raw URL + init, skipping Request construction.
|
|
188
191
|
* Used by SandboxAction.h2Fetch() for direct calls from subsystems.
|
|
@@ -153,6 +153,15 @@ class H2Pool {
|
|
|
153
153
|
return session;
|
|
154
154
|
}
|
|
155
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 ->
|
|
158
|
+
// attachEvictionListeners, see above) may have deleted or replaced this
|
|
159
|
+
// entry. `entry` is the exact object held in the map, so if it is no
|
|
160
|
+
// longer the cached generation, refuse the now-stale session instead of
|
|
161
|
+
// handing back a zombie — the ENG-2422 failure re-entering through the
|
|
162
|
+
// validate race. The caller falls through to establish a fresh session.
|
|
163
|
+
if (this.sessions.get(domain) !== entry)
|
|
164
|
+
return null;
|
|
156
165
|
this.markUsed(domain, session);
|
|
157
166
|
return session;
|
|
158
167
|
}
|
|
@@ -11,8 +11,8 @@ const index_js_1 = require("../authentication/index.js");
|
|
|
11
11
|
const env_js_1 = require("../common/env.js");
|
|
12
12
|
const node_js_1 = require("../common/node.js");
|
|
13
13
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
14
|
-
const BUILD_VERSION = "0.2.87-preview.
|
|
15
|
-
const BUILD_COMMIT = "
|
|
14
|
+
const BUILD_VERSION = "0.2.87-preview.170";
|
|
15
|
+
const BUILD_COMMIT = "0988680b8e320e4f8a4e0007eec9a30cb043aac2";
|
|
16
16
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
17
17
|
const BLAXEL_API_VERSION = "2026-04-16";
|
|
18
18
|
// Cache for config.yaml tracking value
|
|
@@ -10,13 +10,18 @@ import type { H2Pool } from "./h2pool.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function createH2Fetch(session: http2.ClientHttp2Session): (input: Request) => Promise<Response>;
|
|
12
12
|
/**
|
|
13
|
-
* Creates a fetch()-compatible function backed by the H2 session pool
|
|
13
|
+
* Creates a fetch()-compatible function backed by the H2 session pool, routed
|
|
14
|
+
* through the single gateway. Used as the generated client's `fetch`.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* are sent.
|
|
16
|
+
* If no usable H2 session is available, the request falls back to regular fetch
|
|
17
|
+
* before any H2 frames are sent.
|
|
18
18
|
*/
|
|
19
19
|
export declare function createPoolBackedH2Fetch(pool: H2Pool, domain: string): (input: Request) => Promise<Response>;
|
|
20
|
+
/**
|
|
21
|
+
* Pool-backed H2 request taking raw url + init (skips Request allocation),
|
|
22
|
+
* routed through the same single gateway. Used by `SandboxAction.h2Fetch` and
|
|
23
|
+
* the code interpreter.
|
|
24
|
+
*/
|
|
20
25
|
export declare function h2RequestDirectFromPool(pool: H2Pool, domain: string, url: string, init?: RequestInit): Promise<Response>;
|
|
21
26
|
/**
|
|
22
27
|
* Low-level H2 request that takes raw URL + init, skipping Request construction.
|