@hwip/cli 0.1.24 → 0.1.25
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/http-failure.d.ts +13 -3
- package/dist/http-failure.js +21 -4
- package/dist/listener.js +1 -0
- package/package.json +1 -1
package/dist/http-failure.d.ts
CHANGED
|
@@ -76,16 +76,26 @@ export interface ProxyConfig {
|
|
|
76
76
|
*
|
|
77
77
|
* Not through Node's own `http.setGlobalProxyFromEnv`: it exists only from 24.14
|
|
78
78
|
* and 25.4, and the CLI runs on older Nodes. `fetch` gets undici's
|
|
79
|
-
* `EnvHttpProxyAgent` as the global dispatcher (undici 6, Node >= 18.17
|
|
79
|
+
* `EnvHttpProxyAgent` as the global dispatcher (undici 6, Node >= 18.17 — Node 26's
|
|
80
|
+
* own fetch ignores it; the daemon swaps in undici's fetch, `useHttp1Transport`); `ws`
|
|
80
81
|
* opens its own connection, so it gets a CONNECT-tunnelling agent from
|
|
81
|
-
* `https-proxy-agent` (`webSocketProxyOptions`). Both libraries load only here
|
|
82
|
-
* so a run with no proxy pays nothing for them.
|
|
82
|
+
* `https-proxy-agent` (`webSocketProxyOptions`). Both libraries load only here
|
|
83
|
+
* (undici also in the daemon), so a command run with no proxy pays nothing for them.
|
|
83
84
|
*
|
|
84
85
|
* A proxy that cannot be set up is an error, not a direct connection: going
|
|
85
86
|
* around a proxy someone configured is the wrong way to fail. The error names
|
|
86
87
|
* the setting and never quotes it: the value may carry the proxy's password.
|
|
87
88
|
*/
|
|
88
89
|
export declare const useProxyFromEnv: (env?: ProxyEnv, config?: ProxyConfig) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Pin the daemon's `fetch` to HTTP/1.1: an aborted HTTP/2 upload on Node 26 wedged the
|
|
92
|
+
* event loop in nghttp2's send loop (one shared session); HTTP/1.1 gives each request its
|
|
93
|
+
* own socket. Node 26's fetch (undici 8) reads `undici.globalDispatcher.2`, undici 6 writes
|
|
94
|
+
* `.1`, and an undici 6 dispatcher handed to Node 26's fetch fails "invalid onError method"
|
|
95
|
+
* — so the fetch is swapped for undici 6's own, which also makes `useProxyFromEnv`'s proxy
|
|
96
|
+
* agent apply again. Daemon only (`cli-lazy-load.test.ts`); call after `useProxyFromEnv`.
|
|
97
|
+
*/
|
|
98
|
+
export declare const useHttp1Transport: () => Promise<void>;
|
|
89
99
|
/**
|
|
90
100
|
* Options for the listener's `new WebSocket`: `ws` opens its own connection
|
|
91
101
|
* and never reaches fetch's dispatcher, so with a proxy set it is handed an
|
package/dist/http-failure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webSocketProxyOptions = exports.useProxyFromEnv = exports.proxyForUrl = exports.AUTH_HINT = exports.httpFailureMessage = exports.readJsonBody = exports.networkFailureMessage = exports.isUnsendableHeader = exports.isConfigFailure = exports.isInvalidUrl = exports.neverConnected = exports.isRedirectRefusal = void 0;
|
|
3
|
+
exports.webSocketProxyOptions = exports.useHttp1Transport = exports.useProxyFromEnv = exports.proxyForUrl = exports.AUTH_HINT = exports.httpFailureMessage = exports.readJsonBody = exports.networkFailureMessage = exports.isUnsendableHeader = exports.isConfigFailure = exports.isInvalidUrl = exports.neverConnected = exports.isRedirectRefusal = void 0;
|
|
4
4
|
const redact_js_1 = require("./redact.js");
|
|
5
5
|
const ws_url_js_1 = require("./ws-url.js");
|
|
6
6
|
/**
|
|
@@ -273,10 +273,11 @@ const configProxyValue = (key, config) => {
|
|
|
273
273
|
*
|
|
274
274
|
* Not through Node's own `http.setGlobalProxyFromEnv`: it exists only from 24.14
|
|
275
275
|
* and 25.4, and the CLI runs on older Nodes. `fetch` gets undici's
|
|
276
|
-
* `EnvHttpProxyAgent` as the global dispatcher (undici 6, Node >= 18.17
|
|
276
|
+
* `EnvHttpProxyAgent` as the global dispatcher (undici 6, Node >= 18.17 — Node 26's
|
|
277
|
+
* own fetch ignores it; the daemon swaps in undici's fetch, `useHttp1Transport`); `ws`
|
|
277
278
|
* opens its own connection, so it gets a CONNECT-tunnelling agent from
|
|
278
|
-
* `https-proxy-agent` (`webSocketProxyOptions`). Both libraries load only here
|
|
279
|
-
* so a run with no proxy pays nothing for them.
|
|
279
|
+
* `https-proxy-agent` (`webSocketProxyOptions`). Both libraries load only here
|
|
280
|
+
* (undici also in the daemon), so a command run with no proxy pays nothing for them.
|
|
280
281
|
*
|
|
281
282
|
* A proxy that cannot be set up is an error, not a direct connection: going
|
|
282
283
|
* around a proxy someone configured is the wrong way to fail. The error names
|
|
@@ -334,6 +335,22 @@ const useProxyFromEnv = async (env = process.env, config = {}) => {
|
|
|
334
335
|
};
|
|
335
336
|
};
|
|
336
337
|
exports.useProxyFromEnv = useProxyFromEnv;
|
|
338
|
+
/**
|
|
339
|
+
* Pin the daemon's `fetch` to HTTP/1.1: an aborted HTTP/2 upload on Node 26 wedged the
|
|
340
|
+
* event loop in nghttp2's send loop (one shared session); HTTP/1.1 gives each request its
|
|
341
|
+
* own socket. Node 26's fetch (undici 8) reads `undici.globalDispatcher.2`, undici 6 writes
|
|
342
|
+
* `.1`, and an undici 6 dispatcher handed to Node 26's fetch fails "invalid onError method"
|
|
343
|
+
* — so the fetch is swapped for undici 6's own, which also makes `useProxyFromEnv`'s proxy
|
|
344
|
+
* agent apply again. Daemon only (`cli-lazy-load.test.ts`); call after `useProxyFromEnv`.
|
|
345
|
+
*/
|
|
346
|
+
const useHttp1Transport = async () => {
|
|
347
|
+
const undici = await import('undici');
|
|
348
|
+
// With a proxy, its agent is already the dispatcher (HTTP/1.1, undici 6's default).
|
|
349
|
+
if (!active)
|
|
350
|
+
undici.setGlobalDispatcher(new undici.Agent({ allowH2: false }));
|
|
351
|
+
globalThis.fetch = undici.fetch;
|
|
352
|
+
};
|
|
353
|
+
exports.useHttp1Transport = useHttp1Transport;
|
|
337
354
|
/**
|
|
338
355
|
* Options for the listener's `new WebSocket`: `ws` opens its own connection
|
|
339
356
|
* and never reaches fetch's dispatcher, so with a proxy set it is handed an
|
package/dist/listener.js
CHANGED
|
@@ -6121,6 +6121,7 @@ const handleListener = async (args) => {
|
|
|
6121
6121
|
`Tail \`~/.hwip/listener.log\` to follow it, or kill ${otherPid} first.`);
|
|
6122
6122
|
return 0;
|
|
6123
6123
|
}
|
|
6124
|
+
await (0, http_failure_js_1.useHttp1Transport)();
|
|
6124
6125
|
const settings = (0, exports.listenerSettings)(args);
|
|
6125
6126
|
if ('exit' in settings) {
|
|
6126
6127
|
console.error(settings.message);
|