tunnelfetch 1.6.2 → 1.6.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tunnelfetch",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "A fetch-shaped HTTP client that can route through HTTP CONNECT / HTTPS / SOCKS5 proxies on runtimes with only raw TCP, such as Cloudflare Workers. Implements TLS in userland because the runtime cannot verify a tunnelled peer.",
5
5
  "keywords": [
6
6
  "fetch",
@@ -201,7 +201,21 @@ export class Http2Connection {
201
201
 
202
202
  // Our advertised settings. The defaults ARE the fingerprint (see constants.js); overrides
203
203
  // exist for tests, and shifting them shifts what the server sees, so production leaves them.
204
- this._ourInitialWindow = opts.initialWindowSize ?? CLIENT_INITIAL_WINDOW_SIZE;
204
+ // The window we ADVERTISE and the window we ACCOUNT FOR must be the same number, and until
205
+ // 1.6.3 they were two independent settings that silently disagreed.
206
+ //
207
+ // `opts.settings` is the SETTINGS flight, which is how a fingerprint profile states its
208
+ // identity; SETTINGS_INITIAL_WINDOW_SIZE (id 4) inside it is what the peer is told. This field
209
+ // is what `_replenish` measures against — it only emits a WINDOW_UPDATE once the consumer has
210
+ // drained half of it. Take them from different places and a profile advertising 64 KiB against
211
+ // a default accounting of 10 MiB sets a replenish threshold of 5 MiB that a 64 KiB window can
212
+ // never reach: the peer sends one window's worth, stops, and no WINDOW_UPDATE ever comes. Every
213
+ // response larger than the advertised window hangs until the idle deadline fires.
214
+ //
215
+ // That is not hypothetical — `profiles.curl` gained curl 8.21.0's real 65536 in 1.6.2 and this
216
+ // is what it did. One source of truth: if the flight names id 4, that IS the window.
217
+ const advertised = (opts.settings ?? []).find(([id]) => id === 0x4)?.[1];
218
+ this._ourInitialWindow = opts.initialWindowSize ?? advertised ?? CLIENT_INITIAL_WINDOW_SIZE;
205
219
  this._ourConnWindow = opts.connectionWindow ?? CLIENT_CONNECTION_WINDOW;
206
220
  this._ourMaxConcurrent = opts.maxConcurrentStreams ?? CLIENT_MAX_CONCURRENT_STREAMS;
207
221
  this._ourHeaderTableSize = opts.maxHeaderTableSize ?? DEFAULT_HEADER_TABLE_SIZE;